Skip to main content

Python SDK to access Xero APIs

Project description

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>'
)
  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 an Invoice by id
response = connection.Invoices.get_by_id(<invoice_id>)

NOTE: Only Invoices, Accounts, Contacts 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

Project details


Release history Release notifications

Download files

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

Files for xerosdk, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size xerosdk-0.1.0-py3-none-any.whl (10.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size xerosdk-0.1.0.tar.gz (7.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page