Before we dive in β try it right now, no signup required:
π receipt-parser-demo.netlify.app
Upload any receipt image and see the structured JSON output in seconds.
The Problem With Receipt OCR
Building any kind of expense tracker, reimbursement tool, or bookkeeping automation means you eventually need to extract data from receipts. The standard approaches are painful:
- Regex on raw OCR text β works until it doesn't. Fonts, layouts, and languages break it constantly.
- AWS Textract / Google Document AI β powerful, but requires IAM setup, SDK configuration, and significant engineering time before you get a single result.
- Tesseract β open source and flexible, but returns raw text with no semantic structure. You still need to parse "what is the total?" yourself.
What you actually want is a simple API call that returns structured JSON: merchant name, date, line items, totals, tax, tips, and payment method β without any of the setup overhead.
That's what the Receipt Parser API does. Let's walk through how to use it.
What You'll Build
By the end of this tutorial, you'll have a working script that:
- Accepts a receipt image (JPG, PNG, or PDF)
- Calls the Receipt Parser API
- Returns structured JSON with 50+ fields extracted
Prerequisites
- A RapidAPI account (free tier available β 5 parses/month at no cost)
- Python 3.7+ or Node.js 14+
- Any receipt image to test with
Get your API key: Subscribe on RapidAPI β the Basic tier is free.
Step 1: Get a Receipt Image
You can use any receipt: grocery store, restaurant, Uber, Amazon, gym β the API handles them all. For this tutorial, grab any receipt photo from your phone.
Not ready to use a real receipt? The live demo includes sample receipts (Restaurant, Grocery, Gym Invoice) you can click to test instantly.
Step 2: Call the API (Python)
import requests
import base64
import json
def parse_receipt(image_path: str, api_key: str) -> dict:
with open(image_path, "rb") as f:
image_data = base64.b64encode(f.read()).decode("utf-8")
response = requests.post(
"https://receipt-parser2.p.rapidapi.com/parse",
headers={
"x-rapidapi-key": api_key,
"x-rapidapi-host": "receipt-parser2.p.rapidapi.com",
"Content-Type": "application/json",
},
json={"image": image_data},
)
response.raise_for_status()
return response.json()
result = parse_receipt("receipt.jpg", "YOUR_RAPIDAPI_KEY")
print(json.dumps(result, indent=2))
That's it. Five meaningful lines of logic.
Step 3: Call the API (Node.js)
const axios = require("axios");
const fs = require("fs");
async function parseReceipt(imagePath, apiKey) {
const imageData = fs.readFileSync(imagePath, { encoding: "base64" });
const response = await axios.post(
"https://receipt-parser2.p.rapidapi.com/parse",
{ image: imageData },
{
headers: {
"x-rapidapi-key": apiKey,
"x-rapidapi-host": "receipt-parser2.p.rapidapi.com",
"Content-Type": "application/json",
},
}
);
return response.data;
}
parseReceipt("receipt.jpg", "YOUR_RAPIDAPI_KEY").then((result) =>
console.log(JSON.stringify(result, null, 2))
);
What the JSON Response Looks Like
Here's actual output from a grocery receipt:
{
"merchant": {
"name": "Whole Foods Market",
"address": "945 Bryant St, San Francisco, CA 94103",
"phone": "(415) 618-0066"
},
"transaction": {
"date": "2025-03-14",
"time": "14:32",
"receipt_number": "00482-391"
},
"items": [
{ "description": "Organic Bananas", "quantity": 1, "unit_price": 1.49, "total": 1.49 },
{ "description": "Oat Milk 64oz", "quantity": 2, "unit_price": 5.99, "total": 11.98 },
{ "description": "Sourdough Bread", "quantity": 1, "unit_price": 6.49, "total": 6.49 }
],
"totals": {
"subtotal": 19.96,
"tax": 1.40,
"total": 21.36,
"tip": null,
"discount": 0.00
},
"payment": {
"method": "VISA",
"last_four": "4821",
"change_due": null
}
}
And from a restaurant receipt:
{
"merchant": {
"name": "The Bird SF",
"address": "115 New Montgomery St, San Francisco, CA"
},
"transaction": {
"date": "2025-03-15",
"time": "12:18"
},
"items": [
{ "description": "Chicken Sandwich", "quantity": 1, "unit_price": 14.00, "total": 14.00 },
{ "description": "Side Fries", "quantity": 1, "unit_price": 4.00, "total": 4.00 },
{ "description": "Fountain Drink", "quantity": 1, "unit_price": 3.00, "total": 3.00 }
],
"totals": {
"subtotal": 21.00,
"tax": 1.89,
"tip": 4.20,
"total": 27.09
},
"payment": {
"method": "Mastercard",
"last_four": "7734"
}
}
Fields Covered
The API extracts 50+ fields across these categories:
| Category | Fields |
|---|---|
| Merchant | name, address, phone, website, tax ID |
| Transaction | date, time, receipt number, order number |
| Line items | description, quantity, unit price, total, modifiers |
| Totals | subtotal, tax, tip, discount, total, change |
| Payment | method, card type, last four digits |
| Currency | detected currency code |
Error Handling
from requests.exceptions import HTTPError
try:
result = parse_receipt("receipt.jpg", "YOUR_RAPIDAPI_KEY")
except HTTPError as e:
if e.response.status_code == 429:
print("Rate limit hit β upgrade your plan or wait")
elif e.response.status_code == 422:
print("Could not parse image β try a clearer photo")
else:
raise
What to Build Next
With structured receipt JSON, you can:
- Expense tracker: Automatically categorize and log expenses to a spreadsheet or database
- Reimbursement tool: Extract line items for approval workflows
- Bookkeeping automation: Feed parsed data directly into QuickBooks or Xero
- n8n/Zapier workflows: Trigger automations when a receipt is uploaded
Try It Live
Before writing a single line of code, see what the JSON output looks like for your specific use case:
π Live Demo β no signup required
Upload a receipt and see the full JSON response in under 5 seconds.
Ready to integrate? Subscribe on RapidAPI β the Basic tier is free and includes 5 parses/month with no credit card required.
Have questions about a specific receipt type or use case? Drop a comment below.
Top comments (0)