Get Expense Data from Xero API Using Python
Step-by-step guide to retrieving expense data from the Xero API using OAuth 2.0 authentication. Learn endpoints, implementation steps, common pitfalls, and FAQs.
The Xero MCP Server needs no signup. One click, one command or one link connects Claude, ChatGPT, Cursor or Codex to it, with a free trial of 2,000 calls over 30 days.
Opens Claude with Knit filled in: click Continue. Claude web and desktop share one connector list. Or paste this link in Settings > Connectors > Add custom connector.
curl -fsSL https://raw.githubusercontent.com/knitapi/knit-plugin/main/plugins/knit/skills/knit/scripts/install.sh | bash -s -- --agents claude
Run in your own terminal, then restart Claude Code. Adds the server, the Knit skill and a CLAUDE.md note.
Turn on developer mode, then create a connector named Knit with this link and No Auth.
curl -fsSL https://raw.githubusercontent.com/knitapi/knit-plugin/main/plugins/knit/skills/knit/scripts/install.sh | bash -s -- --agents codex
Run in your own terminal (not through Codex), then start a new Codex session.
curl -fsSL https://raw.githubusercontent.com/knitapi/knit-plugin/main/plugins/knit/skills/knit/scripts/install.sh | bash -s -- --agents antigravity
Run in your own terminal, then reload MCP servers (/mcp in the CLI, refresh in the IDE).
curl -fsSL https://raw.githubusercontent.com/knitapi/knit-plugin/main/plugins/knit/skills/knit/scripts/install.sh | bash -s -- --agents cursor
Run in your own terminal, restart Cursor, then paste the note it prints into User Rules.
Xero also publishes an official Xero MCP server. Here's how the two compare.
If Xero is the only app your agent needs, the official server is a good fit. Knit fits when your agent works across several apps, or when you want to skip setting up auth for each one.
Google for Startups AcceleratorOne hosted MCP server for Xero and every other app your agent needs, with sign-in handled and missing tools built on demand.
Knit runs the Xero MCP Server for you. Add one link or one command to your agent; there is no server to deploy and no signup.
The same Knit connection that reaches Xero reaches every other app Knit supports, so your agent can work across apps without a server per app.
If the tool your agent needs isn't there yet, Knit reads the app's public API docs and builds the call when your agent asks.
Your agent describes the task in plain language and Knit returns the API calls that do it.
Claude, ChatGPT, Cursor, Codex, Claude Code, Antigravity or your own MCP client: one click, one command or one link.
Your agent sends you a link to connect Xero once. Knit stores and refreshes the credentials, so you never handle tokens.
Watch an agent automate workflows — all with Knit's plug-and-play MCP Servers.
Every action below is real and already live — not a roadmap item. Browse the full API reference →
This API endpoint allows the creation of a payment in the accounting system. It supports various applications such as Xero, Zohobooks, Microsoft Dynamics 365, Sage Intacct, Quickbooks, Netsuite, and Freshbooks. The request requires headers specifying 'accept' and 'content-type' as 'application/json'. The body must include 'accountId', 'contactId', 'amount', 'invoiceId', 'paymentLinkedTo', and 'linkedInvoices'. Optional fields include 'date', 'description', 'currency', 'exchangeRate', and 'metaData'. The response returns a success status and the 'paymentId' if successful, or an error message if failed.
The Create Accounting Expense API allows users to create a new expense record in the accounting system. The request requires a transaction date, total amount, and line items as mandatory fields. Optional fields include employee ID, contact ID, company ID, description, currency, and metadata. The response returns a success status and the ID of the created expense if successful, or an error message if the request fails.
This API endpoint allows the creation of an accounting account. It supports various applications like Xero, Zohobooks, Microsoft Dynamics 365, Sage Intacct, Quickbooks, Netsuite, and Freshbooks. The request requires a JSON body with 'name' and 'category' as mandatory fields. The 'category' can be either 'BANK_ACCOUNT' or 'LEDGER_ACCOUNT'. Additional optional fields include 'type', 'subType', 'accountCode', 'accountNumber', 'description', and 'metaData'. The response returns a success status and the unique 'accountId' of the created account. In case of an error, a descriptive error message is provided.
This API endpoint allows the creation of a journal entry with specified details. The request must include headers specifying 'accept' and 'content-type' as 'application/json'. The body of the request requires 'date', 'lineItems', and 'description' as mandatory fields. 'lineItems' is an array of objects, each containing 'accountId', 'amount', 'notes', 'transactionType', 'contactType', and 'contactId'. Optional fields include 'currency', 'referenceNumber', and 'metaData'. The response returns a success status and a 'journalId' if successful, or an error message if unsuccessful.
This API endpoint retrieves tracking categories used for financial reporting purposes. It supports various applications such as Xero, Microsoft Dynamics 365, Quickbooks, Netsuite, and Freshbooks. The request requires an 'accept' header with 'application/json' and optionally a 'categoryId' query parameter to specify a particular tracking category. The response includes a success flag and data containing an array of tracking categories with details such as id, name, creation and update timestamps, category type, status, description, and parent category information.
This API endpoint retrieves tax rates from an accounting application. It supports various apps such as Xero, Zohobooks, Microsoft Dynamics 365, Sage Intacct, Quickbooks, Netsuite, and Freshbooks. The API method is GET, and it requires an 'accept' header with 'application/json'. Optionally, a 'taxRateId' can be provided as a query parameter to fetch details of a specific tax rate. The response includes a success flag, and if successful, a list of tax rates with details such as id, name, code, type, creation and update timestamps, status, description, effective and total tax rates, and components. In case of an error, an error message is returned.
The Update Accounting Invoice API allows users to update an existing invoice in various supported applications such as Xero, Zohobooks, Microsoft Dynamics 365, Sage Intacct, Quickbooks, Netsuite, and Freshbooks. The API requires a POST request with headers specifying 'accept' and 'content-type' as 'application/json'. The request body must include 'type', 'invoiceId', 'contactId', and 'lineItems'. Additional optional fields include 'invoiceNumber', 'status', 'issueDate', 'dueDate', 'paidOnDate', 'currency', 'exchangeRate', 'description', 'totalAmount', 'totalTax', 'totalDiscount', and 'metaData'. The response will indicate success or failure, with a success response containing a 'success' boolean and a failure response containing an 'error' object with a descriptive message.
This API endpoint allows the creation of a new accounting contact. The request requires a POST method to the specified URL with headers indicating 'accept' and 'content-type' as 'application/json'. The request body must include 'name' and 'contactType' as required fields, with optional fields such as 'contactPersonFirstName', 'contactPersonLastName', 'email', 'phoneNumber', 'taxNumber', 'addresses', and 'metaData'. The response will return a success status with a 'contactId' if successful, or an error message if unsuccessful.
This API endpoint allows you to retrieve basic information about companies related to your accounting app. It supports various apps such as Xero, Zohobooks, Microsoft Dynamics 365, Quickbooks, Freshbooks, and Netsuite. The request is made using the GET method and requires an 'accept' header with 'application/json'. You can optionally provide a 'companyId' as a query parameter to fetch details for a specific company. The response includes a success flag and data containing an array of company details such as id, name, legal name, tax number, fiscal year start month and day, creation date, active status, currency, URLs, addresses, phone numbers, and contact information.
The Update Payment Details API allows updating payment information linked to invoices or bills. It requires parameters such as paymentId, accountId, contactId, amount, invoiceId, and paymentLinkedTo. Optional fields include date, description, currency, exchangeRate, linkedInvoices, and metaData. The response indicates success or failure with an optional error message.
The Create Accounting Invoice API allows users to create an invoice or bill in the accounting system. The request requires a JSON body with the type of document (INVOICE or BILL), a contact ID, and at least one line item. Additional optional fields include status, invoice number, issue date, due date, paid on date, currency, exchange rate, description, total amount, total tax, total discount, and metadata. The response returns a success status and the created invoice ID if successful, or an error message if the request fails.
The Get Accounting Items API allows customers to retrieve records of products and services they buy and sell. It supports various applications such as Xero, Zohobooks, Microsoft Dynamics 365, Quickbooks, Netsuite, and Freshbooks. The API accepts a query parameter 'itemId' to fetch details of a specific item. The response includes details such as item ID, name, code, type, creation and update timestamps, status, description, total quantity, unit price, sales details, and purchase details. In case of an error, a descriptive error message is returned.
The Update Accounting Account API allows users to update details of an existing accounting account. The API requires the accountId and category as mandatory fields in the request body. The category can be either BANK_ACCOUNT or LEDGER_ACCOUNT. The API supports various accounting applications such as Xero, Zohobooks, Microsoft Dynamics 365, Sage Intacct, Quickbooks, Netsuite, and Freshbooks. The response indicates whether the update was successful or not, and in case of an error, a descriptive message is provided.
The Update Accounting Contact API allows users to update contact information in supported accounting applications such as Xero, Zohobooks, Microsoft Dynamics 365, Sage Intacct, Quickbooks, Netsuite, and Freshbooks. The API requires a POST request with headers specifying 'accept' and 'content-type' as 'application/json'. The request body must include 'name', 'contactType', and 'contactId' as required fields, along with optional fields such as 'contactPersonFirstName', 'contactPersonLastName', 'email', 'phoneNumber', 'taxNumber', 'addresses', and 'metaData'. The response will indicate success with a boolean and may include additional data or an error message if applicable.
Our AI Agent builds it instantly.
Try NowSee how teams put Xero to work as part of a bigger workflow.
Connect your AR/AP automation platform to QuickBooks, Xero, NetSuite, Sage, and 12+ accounting and ERP systems. Enable your…
Connect your FP&A platform to Oracle, SAP, Microsoft Dynamics, and 100+ ERPs and data sources. Enable finance teams…
Pull credit scores/KYC data, import borrower bank statements, and push repayment schedules into accounting alongside chart-of-accounts and AP/AR…
See how leading technology firms are scaling their operations
Amazing Product With Exceptional Support from the team. By using Knit we managed to speed up our development by orders of magnitude.
A brilliant tool to let you seamlessly integrate with many different systems. It is very easy to integrate with and customer support is next level.
Seamless integration experience. Well-documented, self-explanatory APIs, and excellent service and support.
Easy to integrate. Knit's dashboard is intuitive for setting up and testing integrations, and the sandbox is extremely useful during development.
Knit shipped a brand-new Timesheet API in a week and handed us a ready-to-use NetSuite sandbox. That velocity is priceless when you're running payroll in 40+ countries.
4.9 out of 5 stars on G2
Click Add to Claude on this page and confirm in Claude, or copy the one-line command or link for ChatGPT, Cursor, Codex, Claude Code and other agents. There's no signup: the first call starts a free trial of 2,000 calls over 30 days. When your agent first needs Xero, it gives you a link to connect your Xero account.
Yes. Xero publishes its own Xero MCP server. Knit's version adds sign-in that Knit manages for you, one connection for Xero and every other app Knit supports, and tools built on the fly from public API docs when one is missing. If Xero is the only app your agent needs, the official server is a good fit.
Yes. The Knit connection isn't tied to one app: the same server gives your agent Xero and every other app Knit supports, so you add it once.
Yes — the Xero MCP Server is live and already built, not a roadmap item. It exposes Xero's real actions as AI-ready tools your agent can call directly.
Yes. Its actions cover both reads and writes, so your agent can pull data from Xero and push updates back to it, not just query it.
Knit manages Xero's OAuth, credential storage, and refresh for you. The first time your agent needs Xero, it gives you a link to connect your account; there's no auth to configure yourself.
Knit absorbs it. We maintain and update the Xero connector on our end, so the MCP Server keeps working without you tracking Xero's changelog.
No. Knit acts as a stateless passthrough — data is processed on our application server and returned directly to your agent, without being stored on Knit's servers.
Yes. Add Knit to your agent with no signup, and the first call starts a free trial of 2,000 calls over 30 days.
Yes — this MCP server exposes Xero's actions as tools your AI agent can call directly, the same underlying capability previously offered as a standalone LLM Tool integration. MCP is the protocol; the tool-calling access is the same.
Yes — any MCP-compatible client or agent framework can connect to this server and call its exposed actions, regardless of which underlying LLM is driving the agent.
Step-by-step guide to retrieving expense data from the Xero API using OAuth 2.0 authentication. Learn endpoints, implementation steps, common pitfalls, and FAQs.
Your complete guide to Xero API integration. Learn to automate invoicing , reporting , and payroll using Xero's REST API , manage OAuth 2.0, and explore key use cases.
Learn about the common Xero API data models and API end points in this comprehensive Xero API directory