# I Built a Bilingual Invoice-to-JSON API (Here Is the Whole Stack)
Every accounting team I talked to had the same problem: invoices arrive as PDFs and scans, and someone has to retype them into a spreadsheet. Existing OCR APIs are either expensive, English-only, or return a blob of text
Every accounting team I talked to had the same problem: invoices arrive as PDFs and scans, and someone has to retype them into a spreadsheet. Existing OCR APIs are either expensive, English-only, or return a blob of text instead of structured data.
So I built a small REST API that takes a document and returns JSON.
What it does
You POST an image or PDF. You get back:
{
"vendor": "ACME Ltd",
"date": "2026-09-14",
"total": 1240.00,
"currency": "USD",
"line_items": [
{"desc": "Consulting", "qty": 4, "price": 310.00}
]
}
Bilingual out of the box: English and Vietnamese. Eight document types: invoice, receipt, resume, contract, purchase order, and a few more.
The stack
- Python + FastAPI for the service layer
- PaddleOCR for text extraction (handles Vietnamese diacritics well)
- Custom rule + regex layer for field mapping per document type
- Railway for deploy
- RapidAPI as the storefront + billing
Why PaddleOCR
Tesseract struggled with Vietnamese diacritics and with low-quality phone scans. PaddleOCR handled both noticeably better, and it runs CPU-only which keeps hosting cheap.
Why RapidAPI instead of Stripe
I wanted to skip building auth, rate limiting, API keys, and billing. RapidAPI gives all four plus a marketplace where people already search for APIs. For a solo project the tradeoff (they take a cut) was worth it.
What was hard
- Line item detection. Totals are easy. Splitting a table into rows is where most APIs fall over. I ended up using positional heuristics on OCR boxes.
- Vietnamese. Diacritics break naive tokenisers. Normalising before NER helped a lot.
- Mixed-language invoices. Some have English headers and Vietnamese line items. Per-field language detection beat whole-document detection.
Try it
https://rapidapi.com/tuyentn23/api/invoice-to-json-extractor1
Free tier is live. If you build anything that touches invoices or resumes, I would love to know what document type you would want next.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.