All articles
receiptocrapiautomationexpense-management

How to Extract Data from Receipts with an API

Arthur Sterling

Arthur Sterling

Lead Developer Advocate, Parse

How to Extract Data from Receipts with an API

Receipt data entry is one of the most tedious tasks in expense management. Whether you run an expense tracking app, a bookkeeping platform, or a loyalty program, users hand you crumpled photos, blurry scans, and digital PDFs, and expect clean data on the other end.

This guide shows how to automate receipt extraction using the Parse Receipt Parser API, returning 20+ structured fields from any receipt format in a single call.

What the API Extracts

A single request returns a rich JSON object with:

  • Merchant info: Name, address, phone, and expense category
  • Transaction details: Date, time, receipt number, transaction ID
  • Totals: Subtotal, tax, tip, discount, and final total
  • Payment: Method (VISA, CASH, etc.) and last four card digits
  • Line items: Description, quantity, measured amounts (lb, kg, gal), unit price, total
  • Flags: Whether tax is inclusive (VAT/EU style vs. US-style add-on)

The category field automatically classifies the receipt as Groceries, Dining, Fuel, Shopping, Travel, Healthcare, Services, or Entertainment — no rules or lookups needed.

Getting Started

Sign up at cparse.com/dashboard and copy your API key. New accounts include free credit with no credit card required.

The base URL is https://api.cparse.com/receipt/v1.

Python Example

import requests

url = "https://api.cparse.com/receipt/v1/parse"
headers = {"X-API-Key": "YOUR_API_KEY"}

with open("receipt.jpg", "rb") as f:
    response = requests.post(url, files={"file": f}, headers=headers)

result = response.json()[0]
data = result["data"]

print(data["merchant_name"])   # "Super Save Grocery"
print(data["total"])           # 34.30
print(data["category"])        # "Groceries"
print(data["items"])           # list of line items

JavaScript Example

import FormData from 'form-data';
import fs from 'fs';
import axios from 'axios';

const form = new FormData();
form.append('file', fs.createReadStream('receipt.pdf'));

const response = await axios.post('https://api.cparse.com/receipt/v1/parse', form, {
  headers: {
    ...form.getHeaders(),
    'X-API-Key': 'YOUR_API_KEY',
  },
});

const { merchant_name, total, category, items } = response.data[0].data;
console.log(merchant_name, total, category);

Requesting Only the Fields You Need

For lighter payloads, pass a fields query parameter:

curl --request POST \
  --url 'https://api.cparse.com/receipt/v1/parse?fields=merchant_name&fields=total&fields=date&fields=category' \
  --header 'X-API-Key: YOUR_API_KEY' \
  --form 'file=@receipt.pdf'

This reduces response size and speeds up processing, which matters at scale.

Handling Weighted and Measured Items

Grocery and fuel receipts often include items sold by weight or volume. The API handles these through two dedicated fields on each line item:

  • measured_amount — the continuous measure value (e.g. 2.3 for "2.3 lbs")
  • unit_of_measure — normalized unit (lb, kg, gal, l, oz, etc.)

Standard items like a can of soup have quantity: 1 and measured_amount: null.

Supported File Formats

The API accepts PDF, DOCX, JPEG, and PNG files. ZIP archives containing a single receipt file are also supported.

Use Cases

  • Expense apps: Auto-fill expense reports from a photo upload
  • Bookkeeping platforms: Pull merchant, amount, and category for every transaction
  • Loyalty programs: Verify purchases without manual review
  • Tax tools: Gather deductible expenses across all receipt formats

Next Steps

Read the full Receipt Parser API documentation for the complete list of fields, error codes, and request options. Your API key is waiting at cparse.com/dashboard.


Arthur Sterling is the Lead Developer Advocate at Parse.