Import Xero Data to Google Sheets
In this guide, we’ll walk through how to pull Xero accounting data data directly into Google Sheets, using the API Connector add-on for Sheets.
- What Does This Integration Do?
- Before You Begin
- Part 1: Connect to the Xero API
- Part 2: Pull Xero API Data into Sheets
- Part 3: Create a Custom Xero Request
- Part 4: Handle Pagination
- Part 5: API Documentation
What Does This Integration Do?
This integration pulls accounting data from Xero's Accounting API into Google Sheets. It enables the following scopes:
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Connect to the Xero API
The easiest way to get started with the Xero API is through API Connector’s built-in integration.
- In Sheets, open API Connector and create a new request (Extensions > API Connector > Open > Create request)
- Select Xero from the drop-down list of applications
- Under Authorization, click Connect to Xero
- You'll be asked to select an organization and authorize the connection. Click Allow access. If you want to access multiple organizations, you can click Connect again to select additional organizations.
- You'll then be returned to your Google Sheet, and can verify that your Xero connection is active.
Part 2: Pull Data from Xero to Sheets
Now that we’re connected, let’s pull some data into Sheets.
- Under Endpoint, select the resource that you'll be querying. For this example, we'll select
- Under Headers, select the organization for which you'd like to fetch data from the dropdown list.
- Under Request parameters, optionally set the
orderparameter to set the order of results, and the
whereparameter to filter them.
- Choose a destination sheet, name your request, and hit Run to see the report in your sheet.
Note: Besides the standard API endpoints, Xero provides special Reports endpoints to retrieve the most commonly viewed reports (Balance Sheets, Budget Summary, Profit & Loss, etc). You can view these reports in the Endpoint dropdown by scrolling down or searching for "Reports".
Part 3: Create a Custom Xero Request
Here's a sample request setup to demonstrate how it works.
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- In the request form enter the following:
- Request URL:
- When you select Xero from the OAuth menu, you'll see a blue Connect button if you haven't already authorized the connection. Click through to enable the connection.
- If you have multiple company accounts in Xero, you can add them by clicking the
+tenantbutton, and then toggle between them using the dropdown account selector.
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see invoice data populate your sheet.
- Date parameters are optional. If you leave them off, the current month will be returned.
- An earlier version of this article recommended adding a JMESPath snippet of
Reports.Rows.Rowsto restructure Reports data into a tabular format for Sheets. As of 2023-05-13, API Connector will automatically restructure the data such that JMESPath is no longer needed. Requests created prior to the cutoff date will be unaffected.
Part 4: Handle Pagination
Xero limits the number of records returned in each request. By default, only 100 records will be returned unless you use the 'page' parameter as described in their documentation.
To access more than 100 records, loop through pages automatically with pagination handling, like this:
- Pagination type:
- Page parameter:
- Run until: choose when to stop fetching data
Part 5: API Documentation
Official API documentation: https://developer.xero.com/documentation/api/api-overview
Reports documentation: https://developer.xero.com/documentation/api/accounting/reports
- How do I disconnect from Xero?
To disconnect from Xero, click the Manage Connections link and click Disconnect next to the Xero connection. You can also navigate to https://apps.xero.com/!XJG5x/ca/connected (or click your company dropdown > App Store > Connected Apps) and disconnect there.
- What doesn’t your integration do?
This integration does not push data from Google Sheets to Xero. It is a one-way connection that pulls data from Xero to Sheets.
- When and how does data get pulled into Sheets?
Data can be pulled into Sheets by opening your request and manually clicking Run, which will refresh your sheet with the latest data from Xero's API. Alternatively, you can enable scheduling and automatically refresh requests at the cadence you select (up to 1x an hour).
- Can I run scheduled updates more than once an hour?
Scheduled triggers can not run more than once an hour. This limit is set by Google.
- How much data can I pull into Sheets?
There is no specific limit on the amount of data you can pull from Xero's API into Google Sheets. However, Google Sheets only lets requests run for 6 minutes per execution, so very large requests may time out and fail to complete. If you experience issues, please limit requests where possible (e.g. use append mode to fetch new data instead of fetching the entire data set each time).