{"id":6442,"library":"python-quickbooks","title":"QuickBooks Online API Client","description":"python-quickbooks is an actively maintained Python 3 library designed for interacting with the QuickBooks Online API. It provides a convenient object-oriented interface to access and manage QuickBooks data, abstracting away the complexities of the REST API and OAuth 2.0 authentication. The library integrates with `intuit-oauth` for secure authentication. Releases appear on an as-needed basis, with multiple updates throughout the year.","status":"active","version":"0.9.12","language":"en","source_language":"en","source_url":"https://github.com/ej2/python-quickbooks","tags":["quickbooks","accounting","api-client","oauth","intuit"],"install":[{"cmd":"pip install python-quickbooks","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for OAuth 2.0 authentication with Intuit's APIs.","package":"intuit-oauth","optional":false}],"imports":[{"note":"The QuickBooks class is directly available under the top-level package.","wrong":"from quickbooks.client import QuickBooks","symbol":"QuickBooks","correct":"from quickbooks import QuickBooks"},{"note":"AuthClient is part of the `intuit-oauth` dependency, not directly from `python-quickbooks`.","symbol":"AuthClient","correct":"from intuitlib.client import AuthClient"},{"note":"Specific QuickBooks object models are imported from `quickbooks.objects`.","symbol":"Customer","correct":"from quickbooks.objects.customer import Customer"}],"quickstart":{"code":"import os\nfrom intuitlib.client import AuthClient\nfrom quickbooks import QuickBooks\nfrom quickbooks.objects.customer import Customer\n\n# Retrieve credentials from environment variables for security\nCLIENT_ID = os.environ.get('QBO_CLIENT_ID', 'YOUR_CLIENT_ID')\nCLIENT_SECRET = os.environ.get('QBO_CLIENT_SECRET', 'YOUR_CLIENT_SECRET')\nREFRESH_TOKEN = os.environ.get('QBO_REFRESH_TOKEN', 'YOUR_REFRESH_TOKEN')\nCOMPANY_ID = os.environ.get('QBO_COMPANY_ID', 'YOUR_COMPANY_ID') # Also known as Realm ID\nREDIRECT_URI = os.environ.get('QBO_REDIRECT_URI', 'http://localhost:8000/callback')\nENVIRONMENT = os.environ.get('QBO_ENVIRONMENT', 'sandbox') # 'sandbox' or 'production'\n\n# Initialize AuthClient\nauth_client = AuthClient(\n    CLIENT_ID,\n    CLIENT_SECRET,\n    REDIRECT_URI,\n    ENVIRONMENT\n)\n\n# Initialize QuickBooks client\nqb = QuickBooks(\n    auth_client=auth_client,\n    refresh_token=REFRESH_TOKEN,\n    company_id=COMPANY_ID,\n    minorversion=75 # Recommended: use the latest supported minor version\n)\n\ntry:\n    # Automatically refresh token if needed (handled by the library)\n    # Fetch all customers\n    customers = Customer.all(qb=qb, max_results=10) # Limit results for demonstration\n    for customer in customers:\n        print(f\"Customer ID: {customer.Id}, Display Name: {customer.DisplayName}\")\n\n    # Example: Create a new customer (uncomment to run)\n    # new_customer = Customer()\n    # new_customer.DisplayName = \"New Test Customer\"\n    # new_customer.CompanyName = \"Test Company, Inc.\"\n    # new_customer.save(qb=qb)\n    # print(f\"Created new customer: {new_customer.DisplayName} (ID: {new_customer.Id})\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    # Implement robust error handling and token refresh logic in production\n","lang":"python","description":"This quickstart demonstrates how to set up the `AuthClient` and `QuickBooks` client using environment variables for credentials. It then shows how to fetch a list of customers. Ensure you have registered your app with Intuit Developer and obtained `CLIENT_ID`, `CLIENT_SECRET`, `REFRESH_TOKEN`, `COMPANY_ID` (Realm ID), and configured a `REDIRECT_URI`."},"warnings":[{"fix":"Review your application's use of minor versions. Ensure your `QuickBooks` client is initialized with a `minorversion` of 75 or higher (e.g., `minorversion=75`). Test thoroughly to ensure compatibility with the updated API schema. The library automatically sets the minor version to the latest supported, but explicit setting is good practice.","message":"QuickBooks Online API minor versions 1-74 are being deprecated by Intuit starting August 1, 2025. If your application relies on specific behaviors or schemas from these older minor versions, it may break. The `python-quickbooks` library defaults the minor version to the minimum supported version (currently 75 in 0.9.12) which may change behavior for applications not explicitly setting a `minorversion` parameter.","severity":"breaking","affected_versions":"0.9.12 and earlier, affecting API calls made after August 1, 2025."},{"fix":"Upgrade your application to Python 3 (preferably 3.6+). Ensure all project dependencies are Python 3 compatible.","message":"Python 2 support has been completely removed from the library. Attempts to use it in a Python 2 environment will result in errors related to syntax, decorators, and removed dependencies.","severity":"breaking","affected_versions":"0.9.4+"},{"fix":"Replace any direct references to `simplejson` with Python's standard `json` library, or ensure `simplejson` is installed as a top-level dependency if your application explicitly requires it for other reasons.","message":"The `simplejson` dependency was removed. If your application directly imported `simplejson` via an internal `python-quickbooks` path, those imports will now fail.","severity":"deprecated","affected_versions":"0.9.9+"},{"fix":"The `python-quickbooks` library's `QuickBooks` client, when initialized with an `AuthClient` and `refresh_token`, is designed to automatically handle token refreshing. Ensure your application persists the latest `refresh_token` returned by `auth_client.refresh()` for future sessions, as refresh tokens can roll (change upon use).","message":"OAuth 2.0 access tokens have a limited lifespan (typically 1 hour) and require a refresh token to obtain new access tokens. Failure to correctly manage and refresh tokens will lead to `401 Unauthorized` or `400 invalid_grant` errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For larger datasets, use the `start_position` and `max_results` parameters with `all()` methods to paginate through results. Example: `Customer.all(qb=qb, start_position=1, max_results=1000)`.","message":"Queries for objects (e.g., `Customer.all()`) have a default maximum return of 100 entities and an absolute maximum of 1000 entities per single API call. Fetching large datasets requires pagination.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always sanitize or validate any user-provided input before incorporating it into QBL queries to prevent malicious data from being executed against your QuickBooks data.","message":"Directly passing unsanitized user input into QuickBooks Query Language (QBL) can lead to security vulnerabilities (e.g., SQL injection-like attacks).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}