How to read receipts with an OCR API
Plain OCR gives you the receipt's text; to get usable data you also need to pull out the merchant, date, total and tax. Do it in two calls: our OCR API reads the photo ($0.03), then our Document to JSON API turns that text into the fields you name ($0.03), so $0.06 per receipt. Dedicated receipt APIs from Google, AWS, Microsoft, Mindee or Veryfi do it in one step with an account and a key.
Try it free Image to Text API (OCR) — read text from photos and scans · $0.03 / call
Why receipts are hard
Receipts are crumpled, curved, badly lit and printed on thermal paper that fades. Layouts differ for every shop, the total can be labelled Total, Amount due or Balance, and there are often several totals (before tax, card, change).
So the job has two parts: read every character, then decide which number is which. OCR does the first, a field extractor the second.
Step 1: read the photo
POST https://iamai.markets/api/x402/services/z2uYlMYGy6Xs
{"url": "https://example.com/receipt.jpg"}
# or, for a file: {"image_base64": "...", "mime_type": "image/jpeg"}
# paid answer -> result.text (in reading order), result.has_text
Step 2: pull out the fields
POST https://iamai.markets/api/x402/services/YJwWWlLP8th0
{
"text": "<result.text from step 1>",
"fields": {
"merchant": "the shop or company name",
"date": "purchase date as YYYY-MM-DD",
"total": "final amount paid as a number",
"tax": "total tax as a number",
"currency": "3-letter currency code",
"items": "list of items with name and price"
}
}
# paid answer -> result.fields; a field not on the receipt comes back as null
Tips for better results
- Photograph receipts flat, in good light, filling the frame. Keep files under 5 MB.
- E-receipts that are already text PDFs skip step 1: send the PDF link straight to Document to JSON ({"url": ...}), $0.03.
- Check totals in code: the items should add up to the total minus tax. Flag the ones that don't for a person to look at.
- Each call is paid in USDC on Base with an x402 v2 client and charged only when it works.
Receipt APIs compared
| Service | How it works | Trade-off |
|---|---|---|
| Google Document AI, AWS Textract (AnalyzeExpense), Azure Document Intelligence | Pre-trained receipt models, one call | Cloud account, billing and keys; strong at scale |
| Mindee, Veryfi | Receipt and invoice APIs | Sign-up and plans; built for expense apps |
| Tesseract + your own rules | Free OCR, regex for totals | Breaks on new layouts, needs upkeep |
| OCR + Document to JSON (iamai.markets) | Two calls, fields you choose | $0.06 per receipt, no account, needs a USDC wallet |
The product
Questions
Can I choose the fields?
Yes, up to 40, each with a short description such as "tip amount as a number". That is the advantage over fixed receipt models.
Does it invent a value it cannot read?
No. Document to JSON takes values from the text and returns null for anything that is not there.
Can I test it without paying?
Yes. Both APIs have 5 free tries a day on their listing pages (/l/z2uYlMYGy6Xs and /l/YJwWWlLP8th0).
Related
Updated 2026-12-01
