Skip to main content

xero-sdk-py

Python SDK to access Xero APIs

Requirements

  1. Python 3+
  2. Requests library

Installation

Install Xero SDK using pip as follows:

pip install xerosdk

Usage

This SDK requires OAuth2 authentication credentials such as client ID, client secret and refresh token.

  1. Create a connection using the XeroSDK class.
from xerosdk import XeroSDK 

connection = XeroSDK(
    base_url='<XERO_BASE_URL>',
    client_id='<YOUR CLIENT ID>',
    client_secret='<YOUR CLIENT SECRET>',
    refresh_token='<YOUR REFRESH TOKEN>'
)

# tenant_id is required to make a call to any API
tenant_id = connection.tenants.get_all()[0]['tenantId']
connection.set_tenant_id(tenant_id)
  1. Access any of the API classes
"""
USAGE: <XeroSDK INSTANCE>.<API_NAME>.<API_METHOD>(<PARAMETERS>)
"""

# Get a list of all Invoices
response = connection.invoices.get_all()

# Get a list of all Invoices using generator
for response in invoices.list_all_generator():
   print(response)

# Get an Invoice by id
response = connection.invoices.get_by_id(<invoice_id>)

NOTE: Only Tenants, Invoices, Accounts, Contacts, Items and TrackingCategories API classes are defined in this SDK.

Integration Tests

  1. Install pytest package using pip as follows:
pip install pytest
  1. Create a 'test_credentials.json' file at project root directory and enter Xero OAuth2 authentication credentials of your Xero app.
{
  "base_url": "<xero_base_url>",
  "client_id": "<client_id>",
  "client_secret": "<client_secret>",
  "refresh_token": "<refresh_token>"
}
  1. Run integration tests as follows:
python -m pytest tests/integration

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xerosdk-0.14.4.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xerosdk-0.14.4-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file xerosdk-0.14.4.tar.gz.

File metadata

  • Download URL: xerosdk-0.14.4.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for xerosdk-0.14.4.tar.gz
Algorithm Hash digest
SHA256 550ec06abca0d12333ba86fbb5d7f65c6606ac2dfd9aef08b3dae8b0be0cb12b
MD5 09ccd4c02089ced7f23551a631f9cdec
BLAKE2b-256 1598dbe5a684a113d18aea5b184fa7578c5352f72a7efb9faedad9a1c2dc10ea

See more details on using hashes here.

File details

Details for the file xerosdk-0.14.4-py3-none-any.whl.

File metadata

  • Download URL: xerosdk-0.14.4-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for xerosdk-0.14.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8964d66664d3a581dc2be96337675acd0ea179a0be0d674af8f1edc9f7c8bfee
MD5 cad3cff11b6480229f172f529cb166c7
BLAKE2b-256 74c9168985a27dc2feda5a2fa03085865cead13d957ead9b2bde439be6139232

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.14.4 This release

2 files

0.14.3

2 files

0.14.2

2 files

0.14.1

2 files

0.14.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.2

2 files

0.11.1

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page