Back

Xero API Essential Guide

Aug 11, 20246 minute read

What type of API does Xero provide?

API Type

  • Xero uses a REST API for its Accounting API.

Key Details

  • The Xero connector models the Xero Accounting API as relational tables, views, and stored procedures.

  • Xero provides APIs for different areas including:

    • Accounting API
    • Australian Payroll API
    • Files API
    • Fixed Assets API
    • Projects API
  • Authentication is done using OAuth.

API Limitations

  • The Xero API has usage limitations that apply on a per-application and per-organization basis.

  • There are limits on API requests that can be made within certain time periods.

Best Practices

  • When connecting, it's recommended to select all available OAuth scopes to avoid permission conflicts.

  • For batch inserts, the recommended batch size for maximum performance is 50.

In summary, Xero provides a REST API for accessing its various services, with OAuth authentication and some usage limitations to be aware of when integrating.

Does the Xero API have webhooks?

Yes, the official Xero API does have webhooks. Here are the key points about Xero's webhook functionality:

Webhook Availability

Xero offers webhooks as part of their API, allowing developers to subscribe to events and receive real-time notifications when certain actions occur in a Xero organization.

Event Types

Xero webhooks support subscribing to various event types, including:

  • Invoices
  • Contacts
  • Credit notes
  • Payments
  • Bank transactions
  • Accounts
  • Manual journals
  • Purchase orders

Developers can choose which specific event types they want to subscribe to when setting up a webhook.

Creating Webhooks

To create a webhook:

  1. You need to have a Xero app set up in the developer portal.
  2. Configure the webhook endpoint URL in your app settings.
  3. Use the Xero API to create a webhook subscription, specifying the events you want to monitor.

Best Practices

  • Ensure your webhook endpoint can handle the expected volume of events.
  • Implement proper security measures to validate incoming webhook payloads.
  • Use webhook events to keep your application in sync with Xero data in real-time.

Code Example

Here's a basic example of how you might create a webhook subscription using the Xero API:

var webhook = new Webhook { Key = Guid.NewGuid(), PayloadUrl = "https://your-webhook-endpoint.com/xero-events", Events = new List<WebhookEvent> { new WebhookEvent { EventType = "INVOICE.CREATED" }, new WebhookEvent { EventType = "CONTACT.UPDATED" } } }; var response = await xeroClient.Webhooks.CreateWebhookAsync(webhook);

This code creates a new webhook subscription for invoice creation and contact update events.

By using webhooks, you can build more responsive and efficient integrations with Xero, allowing your application to react immediately to changes in Xero data without the need for constant polling.

Rate Limits and other limitations

The Xero API has specific rate limits to manage the volume of requests made by developers. Here are the key points regarding the API rate limits:

Concurrent Limit

  • The concurrent limit is 5 calls in any 1-second period.
  • This limit applies to requests made simultaneously or in quick succession.

Minute Limit

  • The minute limit is 60 calls per minute.
  • This is an average rate, allowing for short bursts of activity as long as the overall rate doesn't exceed 60 calls per minute.

Daily Limit

  • The daily limit is 5000 calls per day.
  • This limit resets at midnight UTC.

Additional Considerations

  • These limits apply per OAuth 2.0 access token.
  • If you exceed these limits, you'll receive a "429 - Too Many Requests" response.
  • The response will include headers indicating which limit was exceeded and when you can make the next request.

Checking API Usage

  • Currently, Xero doesn't provide a built-in way for developers to check their API usage.
  • Developers often think they're hitting the daily limit, but it's usually the 60 calls per minute limit that's being exceeded.
  • You can check the X-Rate-Limit-Problem header in the API response to confirm which limit you're hitting.

Best Practices

  • Implement your own tracking system to monitor API usage.
  • Design your application to handle rate limit errors gracefully.
  • Spread out API calls over time when possible to avoid hitting the limits.
  • If you consistently need more API calls, consider optimizing your integration or contacting Xero for options.

It's worth noting that Xero has expressed interest in providing a developer dashboard for monitoring API usage in the future, but as of now, developers need to manage this aspect themselves.

Latest API Version

The most recent version of the Xero API is not explicitly stated in the provided search results. However, I can provide you with some key information about Xero's API based on the available sources:

API Structure

Xero offers multiple APIs for different purposes:

  1. Accounting API: This is the core API for interacting with Xero's accounting features [3].
  2. Projects API: Specifically designed for project management functionalities [4].
  3. Assets API: Focused on managing fixed assets within Xero [5].

Key Points to Consider

  • Xero maintains release notes for their Accounting API, which suggests regular updates and improvements [1].
  • The API documentation includes a changelog overview, indicating that Xero keeps track of changes and updates to their APIs [2].
  • Each API (Accounting, Projects, Assets) has its own overview page, suggesting they might have separate versioning or update cycles [3][4][5].

Best Practices

  • Always refer to the official Xero Developer documentation for the most up-to-date information on API versions and changes.
  • Check the release notes and changelog regularly to stay informed about new features, improvements, and potential breaking changes.
  • When implementing Xero API integrations, ensure you're using the most recent version compatible with your application's requirements.

While I couldn't provide the exact version number you asked for, I hope this information helps give you an overview of Xero's API structure and where to look for the most current information. For the most accurate and up-to-date version information, I recommend checking the official Xero Developer portal or contacting Xero support directly.

How to get a Xero developer account and API Keys?

To get a developer account for Xero and create an API integration, you need to follow these steps:

1. Sign up for a Xero Developer account

  1. Go to the Xero Developer website.
  2. Click on the "Sign up" button to create a new account.
  3. Fill in the required information and complete the registration process.

2. Choose the type of integration

Xero offers different types of integrations depending on your needs:

  • Web app: Best for web server apps that can securely store a client secret.
  • Mobile or desktop app: For mobile and desktop apps that can't securely store a client secret.
  • Custom connection: For custom, machine-to-machine integrations (only available in UK, AU, and NZ).

3. Set up your integration

For web app and mobile/desktop app integrations:

  1. Visit the Xero Developer Centre.
  2. Learn about the technical requirements for your chosen integration type.
  3. Follow the documentation to set up your integration.
  4. Use OAuth 2.0 for secure access to Xero data.

For custom connections:

  1. Purchase a custom connection subscription for your Xero organisation (only available in AU, NZ, and UK).
  2. Ask your developer to initiate a custom connection from developer.xero.com.
  3. Authorize the custom connection request via email.
  4. Your developer will receive a confirmation and can start the setup process.

What can you do with the Xero API?

Here's the markdown text with the trailing list of URLs and citation references removed, and any URLs inside the content formatted correctly for the markdown file format:

Here's a list of data models you can interact with using the Xero API, along with what is possible for each:

Accounting API

  • Accounts

    • Create, read, update and archive accounts
    • Get account types and system accounts
  • Bank Transactions

    • Create, read and update bank transactions
    • Attach files/images
  • Contacts

    • Create, read, update and delete contacts
    • Manage contact groups
  • Invoices

    • Create, read, update and delete invoices
    • Send invoices to contacts
    • Void invoices
  • Items

    • Create, read, update and delete inventory items
    • Track quantity and value
  • Journals

    • Read journal entries (cannot create/update)
  • Manual Journals

    • Create, read and update manual journals
  • Payments

    • Create and read payments
    • Apply payments to invoices
  • Reports

    • Generate various financial and accounting reports
  • Tax Rates

    • Create, read and update tax rates

Payroll API

  • Employees

    • Manage employee details and payroll information
  • Timesheets

    • Create and manage employee timesheets
  • Pay Runs

    • Process payroll and create pay runs

Files API

  • Files and Folders
    • Upload, download and manage files/folders
    • Associate files with Xero transactions

Fixed Assets API

  • Asset Types

    • Manage fixed asset types
  • Assets

    • Create and manage fixed assets
    • Track depreciation

Bank Feeds API

  • Bank Connections

    • Set up bank feed connections
  • Bank Statements

    • Import bank statement data

Key Points

  • The Accounting API provides the core financial data and operations
  • Some APIs like Bank Feeds require additional approval from Xero
  • APIs can behave differently in terms of request methods (POST/PUT)
  • The data model has some unique aspects compared to other accounting platforms
  • There are rate limits and request size limits to be aware of when using the APIs

In summary, the Xero API provides extensive capabilities to interact with accounting, payroll, files, assets and banking data. The Accounting API offers the most comprehensive set of operations across core financial data models. Proper authentication and adherence to rate limits is important when integrating with the various Xero APIs.