Tutorials · August 13, 2026

How to fetch expense data from QuickBooks API with Python

Kunal Mishra
4 min read
Table of Contents

Introduction

This article is part of an in-depth series on the QuickBooks API, focused on practical, real-world use cases. In this edition, the focus is straightforward: retrieving expense data from the QuickBooks API in a reliable and scalable way.

If you’re building financial integrations, expense analytics, or back-office automation, expense data is foundational. This guide walks through the exact flow, from authentication to data retrieval, without unnecessary abstraction.

For a broader overview of the QuickBooks API, including authentication models, rate limits, and other supported resources, refer to the comprehensive guide available here.

Pre-requisites

Before you begin, ensure the following are in place:

  • An active QuickBooks Online account
  • Access to the QuickBooks Developer Portal
  • OAuth 2.0 client credentials (Client ID and Client Secret)
  • A Python environment set up with required libraries such as requests and json

API Endpoints

The following endpoints are used in this workflow:

  • Authorization Endpoint
    https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer
  • Expense Report Endpoint
    https://quickbooks.api.intuit.com/v3/company/{company_id}/reports/VendorExpenses

Step-by-Step Process

Step 1: Obtain OAuth 2.0 Access Token

Use the authorization code received during the OAuth flow to generate an access token.

import requests, json

def get_oauth_token(client_id, client_secret, redirect_uri, auth_code):
    url = "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer"
    headers = {
        "Content-Type": "application/x-www-form-urlencoded"
    }
    data = {
        "grant_type": "authorization_code",
        "code": auth_code,
        "redirect_uri": redirect_uri,
        "client_id": client_id,
        "client_secret": client_secret
    }
    response = requests.post(url, headers=headers, data=data)
    return response.json().get("access_token")

Step 2: Fetch Expense Data

Once a valid access token is available, use it to call the Vendor Expenses report endpoint.

def get_expense_data(company_id, access_token):
    url = f"https://quickbooks.api.intuit.com/v3/company/{company_id}/reports/VendorExpenses"
    headers = {
        "Authorization": f"Bearer {access_token}",
        "Accept": "application/json"
    }
    response = requests.get(url, headers=headers)
    return response.json()

Common Pitfalls

Most QuickBooks integrations fail for predictable reasons. Watch out for the following:

  1. Incorrect or misconfigured OAuth 2.0 credentials
  2. Expired access tokens not refreshed in time
  3. Invalid or mismatched company ID
  4. Incorrect API endpoint URLs
  5. Network or connectivity issues during API calls
  6. Missing or insufficient API permissions
  7. Exceeding QuickBooks API rate limits

Addressing these early saves significant debugging time later.

Frequently Asked Questions

What is the rate limit for the QuickBooks API?
Rate limits vary by endpoint and usage pattern. Refer to the official QuickBooks API documentation for exact thresholds.

How do I refresh an expired access token?
Use the refresh token flow provided by QuickBooks to obtain a new access token without re-authenticating the user.

Can I access data for multiple companies?
Yes. Each company requires its own authorization and access token.

What format does the API return data in?
All responses are returned in JSON format.

Is there a sandbox environment available?
Yes. QuickBooks provides a sandbox environment for development and testing.

How should API errors be handled?
Inspect the error payload in the API response and map it against QuickBooks error codes and documentation.

Can expense data retrieval be automated?
Yes. Data retrieval can be automated using scheduled scripts or cron jobs, subject to rate limits and token validity.

Knit for QuickBooks API Integration

If you want to avoid managing OAuth flows, token refresh logic, and long-term integration maintenance, Knit offers a faster path.

With a single integration to Knit, you can access QuickBooks APIs without handling authentication, authorization, or ongoing changes yourself. Knit abstracts the operational overhead, allowing teams to focus on product logic rather than plumbing.

For teams scaling accounting integrations across customers, this approach materially reduces risk, effort, and maintenance cost.


Ready to build this integration?
Explore Knit’s Quickbooks integration or read more about our Unified Accounting API.

Written by Kunal Mishra

Changing integration landscape, one organization at a time‍

Keep Reading

#1 in Ease of Integrations

4.9 out of 5 stars

4.9 out of 5 stars on G2

G2 Leader, Spring 2026G2 Fastest Implementation, Spring 2026G2 High Performer, Spring 2026G2 Best Est. ROI, Spring 2026

Put Integrations on Autopilot. Talk to Experts.

Knit is loved by customers across the globe due to our seamless product and white glove support. You'll love us too!

Talk to a Human