QuickBooks Python API Docs | dltHub
Build a QuickBooks-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.
Last updated:
QuickBooks Online is a cloud accounting platform exposing a RESTful Accounting API for accessing company data programmatically. The REST API base URL is https://quickbooks.api.intuit.com/v3/company/{realmId} (production) | https://sandbox-quickbooks.api.intuit.com/v3/company/{realmId} (sandbox) and All requests require OAuth 2.0 Bearer tokens in the Authorization header..
dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv pip install "dlt[workspace]" and start loading QuickBooks data in under 10 minutes.
What data can I load from QuickBooks?
Here are some of the endpoints you can load from QuickBooks:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| customers | /v3/company/{realmId}/customer | GET (single list via query or Query API) | QueryResponse.Customer | Retrieve customers (use query endpoint to list multiple: /v3/company/{realmId}/query?query=select * from Customer) |
| invoices | /v3/company/{realmId}/invoice | GET | QueryResponse.Invoice | Retrieve invoices (list via query API: select * from Invoice) |
| payments | /v3/company/{realmId}/payment | GET | QueryResponse.Payment | Retrieve payments (list via query API) |
| vendors | /v3/company/{realmId}/vendor | GET | QueryResponse.Vendor | Retrieve vendors (list via query API) |
| accounts | /v3/company/{realmId}/account | GET | QueryResponse.Account | Retrieve Chart of Accounts (list via query API) |
| items | /v3/company/{realmId}/item | GET | QueryResponse.Item | Retrieve catalog items (list via query API) |
| bills | /v3/company/{realmId}/bill | GET | QueryResponse.Bill | Retrieve bills (list via query API) |
| sales_receipts | /v3/company/{realmId}/salesreceipt | GET | QueryResponse.SalesReceipt | Retrieve sales receipts (list via query API) |
| journal_entries | /v3/company/{realmId}/journalentry | GET | QueryResponse.JournalEntry | Retrieve journal entries (list via query API) |
| query | /v3/company/{realmId}/query?query= | GET | QueryResponse. | SQL‑like Query API to return lists of entities (use SELECT ... FROM Entity) |
How do I authenticate with the QuickBooks API?
QuickBooks uses OAuth 2.0. Your app obtains client_id and client_secret from the Intuit Developer dashboard, redirects users to the Intuit authorize URL to get an authorization code, then exchanges the code at the token endpoint to receive an access_token (valid ~1 hour) and refresh_token. Include header: Authorization: Bearer <access_token>. Use application/json for request/response bodies.
1. Get your credentials
- Sign in to https://developer.intuit.com and create an app (QuickBooks Online and Payments).
- In the app's Development Settings → Keys & credentials, copy Client ID and Client Secret.
- Configure a Redirect URI in the app settings.
- Send users to the authorize URL (https://appcenter.intuit.com/connect/oauth2) with client_id, scope, response_type=code and redirect_uri.
- Exchange the returned authorization code at the token endpoint (https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer) with client_id and client_secret to get access_token and refresh_token.
- Store access_token (use in Authorization header) and use refresh_token to obtain new access_token before expiry.
2. Add them to .dlt/secrets.toml
[sources.quickbooks_financial_source] client_id = "your_client_id" client_secret = "your_client_secret" refresh_token = "your_refresh_token"
dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.
How do I set up and run the pipeline?
Set up a virtual environment and install dlt:
uv venv && source .venv/bin/activate uv pip install "dlt[workspace]"
1. Install the dlt AI Workbench:
dlt ai init --agent <your-agent> # <agent>: claude | cursor | codex
This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →
2. Install the rest-api-pipeline toolkit:
dlt ai toolkit rest-api-pipeline install
This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →
3. Start LLM-assisted coding:
Use /find-source to load data from the QuickBooks API into DuckDB.
The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.
4. Run the pipeline:
python quickbooks_financial_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline quickbooks_financial_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset quickbooks_financial_data The duckdb destination used duckdb:/quickbooks_financial.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
dlt pipeline quickbooks_financial_pipeline show
This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.
Python pipeline example
This example loads customers and invoices from the QuickBooks API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def quickbooks_financial_source(oauth_credentials=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://quickbooks.api.intuit.com/v3/company/{realmId} (production) | https://sandbox-quickbooks.api.intuit.com/v3/company/{realmId} (sandbox)", "auth": { "type": "bearer", "access_token": oauth_credentials, }, }, "resources": [ {"name": "customers", "endpoint": {"path": "query?query=select * from Customer", "data_selector": "QueryResponse.Customer"}}, {"name": "invoices", "endpoint": {"path": "query?query=select * from Invoice", "data_selector": "QueryResponse.Invoice"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="quickbooks_financial_pipeline", destination="duckdb", dataset_name="quickbooks_financial_data", ) load_info = pipeline.run(quickbooks_financial_source()) print(load_info)
To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.
How do I query the loaded data?
Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("quickbooks_financial_pipeline").dataset() sessions_df = data.customers.df() print(sessions_df.head())
SQL (DuckDB example):
SELECT * FROM quickbooks_financial_data.customers LIMIT 10;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("quickbooks_financial_pipeline").dataset() data.customers.df().head()
See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.
What destinations can I load QuickBooks data to?
dlt supports loading into any of these destinations — only the destination parameter changes:
| Destination | Example value |
|---|---|
| DuckDB (local, default) | "duckdb" |
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.
Troubleshooting
Authentication failures
401 Unauthorized or 400 invalid_grant typically mean the access_token expired, the refresh_token is invalid/expired, or client credentials are incorrect. Refresh tokens roll (use refresh_token endpoint at https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer with grant_type=refresh_token). Ensure Authorization: Bearer <access_token> and correct realmId are used.
Rate limits and throttling
QuickBooks enforces per-realm and per-app throttles (examples: 500 requests/minute per realm; 10 requests/second per realm & app). When throttled you receive HTTP 429. Back off (wait ~60s) and retry with exponential backoff. Batch endpoints have separate limits (payload count and batch-per-minute). See Intuit docs for current limits.
Pagination and large result sets
Query responses are limited (max 1000 entities per response). Use the SQL‑like Query API with startposition and maxresults (e.g. "select * from Customer startposition 1 maxresults 1000") to page through results. The list arrays are returned inside the QueryResponse object, e.g. QueryResponse.Customer.
Common API errors
- 400 Bad Request: malformed request or invalid fields.
- 401 Unauthorized: missing/expired/invalid access token.
- 403 Forbidden: insufficient scopes or restricted resource.
- 404 Not Found: invalid endpoint or entity id.
- 429 Too Many Requests: rate limited — retry after backoff.
- 500/502/503: server errors — retry with backoff.
Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.
Next steps
Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:
data-exploration— Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.dlthub-runtime— Deploy, schedule, and monitor your pipeline in production.
dlt ai toolkit data-exploration install dlt ai toolkit dlthub-runtime install
Was this page helpful?
Community Hub
Need more dlt context for QuickBooks?
Request dlt skills, commands, AGENT.md files, and AI-native context.