A Python 3 library for accessing the Quickbooks API. Complete rework of
quickbooks-python.
These instructions were written for a Django application. Make sure to
change it to whatever framework/method you're using.
You can find additional examples of usage in Integration tests folder.
This library requires intuit-oauth.
Follow the OAuth 2.0 Guide for installation and to get connected to QuickBooks API.
Accessing the API
Set up an AuthClient passing in your CLIENT_ID and CLIENT_SECRET.
from intuitlib.client import AuthClient
auth_client = AuthClient(
client_id='CLIENT_ID',
client_secret='CLIENT_SECRET',
access_token='ACCESS_TOKEN', # If you do not pass this in, the Quickbooks client will call refresh and get a new access token.
environment='sandbox',
redirect_uri='http://localhost:8000/callback',
)
Then create a QuickBooks client object passing in the AuthClient, refresh token, and company id:
Note: Beginning August 1, 2025, Intuit will be deprecating support for minor versions 1–74. See Intuit Blog for more details
Object Operations
List of objects:
from quickbooks.objects.customer import Customer
customers = Customer.all(qb=client)
Note: The maximum number of entities that can be returned in a
response is 1000. If the result size is not specified, the default
number is 100. (See Query operations and syntax for details)
Warning: You should never allow user input to pass into a query without sanitizing it first! This library DOES NOT sanitize user input!
# Get customer invoices ordered by TxnDate
invoices = Invoice.filter(CustomerRef='100', order_by='TxnDate', qb=client)
# Same, but in reverse order
invoices = Invoice.filter(CustomerRef='100', order_by='TxnDate DESC', qb=client)
# Order customers by FamilyName then by GivenName
customers = Customer.all(order_by='FamilyName, GivenName', qb=client)
# successes is a list of objects that were successfully updated
for obj in results.successes:
print("Updated " + obj.DisplayName)
# faults contains list of failed operations and associated errors
for fault in results.faults:
print("Operation failed on " + fault.original_object.DisplayName)
for error in fault.Error:
print("Error " + error.Message)
Change Data Capture
Change Data Capture returns a list of objects that have changed since a given time
(see Change data capture for more details):
from quickbooks.cdc import change_data_capture
from quickbooks.objects import Invoice
cdc_response = change_data_capture([Invoice], "2017-01-01T00:00:00", qb=client)
for invoice in cdc_response.Invoice:
# Do something with the invoice
Note: You can use either _FilePath or _FileBytes to attach a file, but not both at the same time.
Passing in optional params
Some QBO objects have options that need to be set on the query string of an API call.
One example is include=allowduplicatedocnum on the Purchase object. You can add these params when calling save:
The QuickbooksException object contains additional QBO error code information.
from quickbooks.exceptions import QuickbooksException
try:
# perform a Quickbooks operation
except QuickbooksException as e:
e.message # contains the error message returned from QBO
e.error_code # contains the
e.detail # contains additional information when available
Note: Objects and object property names match their Quickbooks
counterparts and do not follow PEP8.
Note: This is a work-in-progress made public to help other
developers access the QuickBooks API. Built for a Django project.
Works well with
Use together with python-quickbooks: extensions, drivers, servers and companion tools.