CookbooksOCR Cookbooks
Build a Receipt Expense Pipeline
Turn a folder of receipts into a deduped expense report with merchant, date, and total.
- OCR every receipt to JSON with ARVA OCR
- Parse merchant, date, and total with Python patterns
- Dedupe repeat scans by file hash
Time to complete: ~15 minutes
Prerequisites
- A
SAGEA_API_KEYexported as an environment variable - Receipt images in PDF, PNG, JPG, TIFF, or WEBP format, max 100MB, ideally 300 DPI
- Python 3.9+ with the
requestspackage installed - Set up document processing
- ARVA OCR model card
Step 1: OCR each receipt to JSON
Loop over a folder and post every file to the OCR endpoint.
Each response contains text, pages, confidence, blocks, and model_used. Accuracy is 99.2% on clean scans across 150+ languages.
Step 2: Parse merchant, date, and total
Extract the three expense fields from OCR text with regular expressions.
Step 3: Dedupe by hash and export CSV
Hash file bytes to drop duplicate scans, then write the expense report.
Standard pages cost $1.00 per 1000 pages, so a thousand receipts cost about one dollar.
Verify
| Error | Cause | Fix |
|---|---|---|
401 Unauthorized | Missing or invalid API key | Export a valid key as SAGEA_API_KEY and retry |
400 unsupported_format | File type not in PDF, PNG, JPG, TIFF, WEBP | Convert the receipt to JPG or PDF and retry |
413 Payload Too Large | File is over 100MB | Compress the image and retry |
429 rate_limit_exceeded | Too many requests at once | Add a short sleep between receipts and retry |
