---
title: "How to fetch expense data from QuickBooks API with Python"
url: "https://getknit.dev/blog/how-to-fetch-expense-data-from-quickbooks-api-with-python/"
date: "2025-12-21T06:28:17+00:00"
modified: "2026-04-11T05:22:12+00:00"
type: "post"
---

# How to fetch expense data from QuickBooks API with Python

[Blog](https://getknit.dev/blog) / [Tutorials](https://getknit.dev/blogs/tutorials/) / How to fetch expense data from QuickBooks API with Python [Tutorials](https://getknit.dev/blogs/tutorials/) · December 21, 2025 · Updated April 11, 2026 

How to fetch expense data from QuickBooks API with Python
=========================================================

 ![](https://storage.googleapis.com/knit-website-media/2026/08/64c34ca1e0546a9d333bb35a_Kunal-3-112x112.png)Kunal Mishra

4 min read

 

 

 [](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgetknit.dev%2Fblog%2Fhow-to-fetch-expense-data-from-quickbooks-api-with-python%2F) [](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgetknit.dev%2Fblog%2Fhow-to-fetch-expense-data-from-quickbooks-api-with-python%2F&text=How%20to%20fetch%20expense%20data%20from%20QuickBooks%20API%20with%20Python)  

 

 

 

  Table of Contents - [Introduction](#introduction)
- [Pre-requisites](#pre-requisites)
- [API Endpoints](#api-endpoints)
- [Step-by-Step Process](#step-by-step-process)
- [Common Pitfalls](#common-pitfalls)
- [Frequently Asked Questions](#frequently-asked-questions)
- [Knit for QuickBooks API Integration](#knit-for-quickbooks-api-integration)
 
  Introduction
------------

This article is part of an in-depth series on the [QuickBooks API](/integration/quickbooks/), 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](/blog/quickbooks-online-api-integration-guide-in-depth/).

### 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](/integration/quickbooks/), 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.

Building a QuickBooks integration?

Knit gives you three ways to build it. Pick the one that fits.

- [QuickBooks on Unified API](https://getknit.dev/integration/quickbooks/)
    
    Your customers want QuickBooks and the other accounting tools they use. Build one integration and get normalised read and write data with real-time webhooks.
    
    [Try free](https://dashboard.getknit.dev/signup)
- [QuickBooks on Integrations Agent](https://getknit.dev/ipaas-connectors/quickbooks-online/)
    
    You need one specific QuickBooks workflow. Describe it in plain English and get production-ready code, not fixed iPaaS blocks.
    
    [Try free](https://agent.getknit.dev/)
- [QuickBooks MCP server](https://getknit.dev/mcp-servers/quickbooks-mcp-server/)
    
    Your AI agent needs to read and act in your customers' QuickBooks. Use a pre-built, hosted MCP server instead of writing integration code.
    
    [Try free](https://mcphub.getknit.dev/)

Knit's Unified API connects to 190+ apps across HRIS, ATS, CRM, accounting and more.

Knit never stores your end users' data and is SOC 2, GDPR and ISO 27001 compliant: [How Knit handles security](/security/) · [Security Center](https://compliance.getknit.dev/)

Not sure which fits? [Talk to a human](/book-demo/)

 

 ![](https://storage.googleapis.com/knit-website-media/2026/08/64c34ca1e0546a9d333bb35a_Kunal-3-112x112.png)Written by Kunal Mishra

Changing integration landscape, one organization at a time‍

 

 

 

 

 

  Keep Reading
------------

  ![Quickbooks Online API Directory](https://storage.googleapis.com/knit-website-media/2026/08/blog-banner-yellow-scaled-640x400.png) [API Directory](https://getknit.dev/blogs/api-directory/) 

### [Quickbooks Online API Directory](https://getknit.dev/blog/quickbooks-online-api-directory/)

Learn about the common Quickbooks API endpoints to build you Quickbooks integration

 September 2, 2024 · 4 min read 

 

   ![Quickbooks Online API Integration Guide (In-Depth): OAuth, Endpoints & Webhooks (2026)](https://storage.googleapis.com/knit-website-media/2026/08/blog-banner-green-640x400.png) [Tutorials](https://getknit.dev/blogs/tutorials/) 

### [Quickbooks Online API Integration Guide (In-Depth): OAuth, Endpoints &amp; Webhooks (2026)](https://getknit.dev/blog/quickbooks-online-api-integration-guide-in-depth/)

The QuickBooks Online API uses OAuth 2.0 via Intuit. Covers app registration, token flow, key entities (invoices, customers, payments), webhooks,…

 August 13, 2024 · 20 min read 

 

   ![How to Get an Okta API Token (Step-by-Step)](https://storage.googleapis.com/knit-website-media/2026/08/blog-banner-red-scaled-640x400.png) [Tutorials](https://getknit.dev/blogs/tutorials/) 

### [How to Get an Okta API Token (Step-by-Step)](https://getknit.dev/blog/okta-api-key/)

Generate an Okta API token in the Admin Console, add it as an SSWS Authorization header, and call the Okta…

 July 22, 2026 · 8 min read 

 

  

 

  \#1 in Ease of Integrations
---------------------------

![4.9 out of 5 stars](/wp-content/themes/knit/assets/images/g2/g2-star-rating.svg)

4.9 out of 5 stars on G2

![G2 Leader, Spring 2026](/wp-content/themes/knit/assets/images/g2/g2-leader.svg)![G2 Fastest Implementation, Spring 2026](/wp-content/themes/knit/assets/images/g2/g2-fastest-implementation.svg)![G2 High Performer, Spring 2026](/wp-content/themes/knit/assets/images/g2/g2-high-performer.svg)![G2 Best Est. ROI, Spring 2026](/wp-content/themes/knit/assets/images/g2/g2-best-roi.svg)

 

  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](/book-demo)
