Prompt
I'm building a receipt capture tool and need an API-first extractor
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
If you want an API-first receipt extractor, the core requirement is:
- Accept receipt images/PDFs via API
- Return structured JSON
- Support async processing for slow OCR / ML extraction
- Be easy to integrate into web/mobile/backend systems
Here’s a solid API-first design you can use.
1) Recommended API shape
Upload / extract
POST /v1/receipts:extract
Request
file(multipart upload) orfile_url- optional
merchant_hint - optional
locale - optional
currency - optional
async=true
Response
{
"request_id": "req_123",
"status": "completed",
"receipt": {
"merchant_name": "Whole Foods Market",
"transaction_date": "2026-10-11",
"transaction_time": "14:32:10",
"currency": "USD",
"subtotal": 18.47,
"tax": 1.66,
"tip": null,
"total": 20.13,
"payment_method": "credit_card",
"last4": "4242",
"items": [
{
"name": "Bananas",
"quantity": 2,
"unit_price": 0.79,
"total_price": 1.58
}
],
"confidence": 0.96
},
"raw_text": "...",
"warnings": []
}
2) Async workflow for real-world reliability
For receipts, sync can work for small files, but API-first systems usually need async support.
Create extraction job
POST /v1/receipts:extract
If async=true, return:
{
"request_id": "req_123",
"status": "processing",
"poll_url": "/v1/receipts/req_123",
"webhook_supported": true
}
Poll result
GET /v1/receipts/{request_id}
Optional webhook callback
receipt.extractedreceipt.failed
This is especially useful for mobile apps and backend workflows.
3) Fields I’d extract
At minimum:
merchant_namemerchant_addresstransaction_datetransaction_timecurrencysubtotaltaxtiptotalitems[]payment_methodlast4receipt_id / transaction_idconfidenceraw_text
Optional but useful:
tax_breakdowndiscountsservice_chargegratuitycash_changecategorycountrylanguage
4) Output schema example
{
"merchant_name": "Target",
"merchant_address": "123 Main St, Austin, TX 78701",
"transaction_date": "2026-10-11",
"transaction_time": "18:04:22",
"currency": "USD",
"subtotal": 54.12,
"tax": 4.38,
"tip": null,
"total": 58.50,
"payment_method": "debit_card",
"last4": "1098",
"items": [
{
"name": "Milk",
"quantity": 1,
"unit_price": 3.49,
"total_price": 3.49
},
{
"name": "Eggs",
"quantity": 2,
"unit_price": 2.25,
"total_price": 4.50
}
],
"confidence": 0.93,
"warnings": [
"Merchant address partially unreadable"
]
}
5) Extraction pipeline architecture
A practical API-first pipeline:
-
File ingestion
- validate file type
- size limits
- virus scan if needed
-
Preprocessing
- image cleanup
- orientation correction
- de-skew
- contrast enhancement
-
OCR
- text detection + recognition
-
Receipt parsing
- merchant identification
- totals and line-item extraction
- date/time normalization
- currency inference
-
Post-processing
- confidence scoring
- field validation
- duplicate detection
- webhook / API response formatting
6) Suggested API endpoints
Minimal set:
POST /v1/receipts:extractGET /v1/receipts/{id}POST /v1/receipts/{id}/reprocessDELETE /v1/receipts/{id}
Useful extras:
POST /v1/webhooksGET /v1/healthGET /v1/modelsPOST /v1/receipts:extract?include_raw_text=true
7) OpenAPI example skeleton
openapi: 3.1.0
info:
title: Receipt Extractor API
version: 1.0.0
paths:
/v1/receipts:extract:
post:
summary: Extract structured data from a receipt
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
async:
type: boolean
merchant_hint:
type: string
required: [file]
responses:
"200":
description: Extraction result
8) Recommended implementation stack
If you’re building this yourself:
- API: FastAPI / Node.js (NestJS, Express)
- OCR: Google Vision, AWS Textract, Azure OCR, or Tesseract for local
- Parsing: rules + ML/LLM hybrid
- Queue: Celery, BullMQ, SQS
- Storage: S3/GCS
- DB: Postgres
- Webhooks: signed callbacks with retries
9) Important product considerations
- Normalize currencies and dates by locale
- Handle blurry / rotated / crumpled receipts
- Support PDFs and multi-page receipts
- Return partial results rather than hard failures
- Keep raw OCR text for debugging
- Provide confidence per field, not just overall
- Add idempotency keys to prevent duplicate jobs
10) If you want the fastest path
If you want an API-first extractor quickly, build:
POST /extractGET /jobs/{id}POST /webhooks- return JSON with:
- merchant
- date
- total
- tax
- items
- confidence
- raw_text
That gives you a clean v1 you can ship.
If you want, I can also generate one of these next:
- a full OpenAPI spec
- a FastAPI implementation
- a Node.js/Express implementation
- a JSON schema for the receipt output
- a production-ready architecture diagram