Hey, community! If youβve ever tried to automate accounts payable, you know the pain of parsing messy PDFs. A new tutorial from Felipe at Anyformat breaks down how to use their invoice data extraction API to turn documents into clean JSON. The key here isnβt just getting text; itβs getting structured records with header fields like invoice number and vendor, plus detailed line items. The best part? Each value comes with a confidence score and evidence of where it was read on the page, which is a game-changer for debugging and verification.
The Three-Step Workflow
The process is refreshingly simple: create a workflow, upload the document, and fetch the result. First, you define a schema using a parse node and an extract node connected by an edge. This schema tells the API exactly what fields you need, such as 'issue_date' or 'total_amount', and even supports nested objects for line items. Once the workflow is set up, you send a POST request to upload your PDF or image. The API returns a run ID and a status of 'queued'. Finally, you poll the runs endpoint until the status changes to 'processed', at which point the structured data is ready for your ERP system.
Understanding the Output
When the extraction is done, the JSON response is rich with metadata. Every field includes a 'value', a 'confidence' score, and an 'evidence' array containing the source text and page number. For example, a line item for 'Cloud hosting' might show a 98% confidence score with the exact text snippet from the invoice. Itβs crucial to note that values arrive as strings, so youβll need to cast them based on your declared data types. Also, if a field isnβt found, the API returns null instead of guessing, which prevents data hallucinations that can plague simpler OCR scripts.
Pricing and Performance Comparison
Anyformat uses a credit-based pricing model. Standard extraction costs 60 credits per page, which translates to β¬0.06 per page on the Business plan or β¬0.09 on pay-as-you-go. This is pricier than AWS Textract or Azure Document Intelligence, which list at around $10 per 1,000 pages for prebuilt models. However, the tutorial argues that the extra cost buys you custom schemas, evidence for every value, and flexibility across document types. If youβre stuck on one cloud and your invoices match their prebuilt models, the hyperscalers are cheaper, but for custom fields and complex layouts, the schema-based approach shines.
Key Takeaways
- Use confidence thresholds to automate high-certainty invoices and route low-confidence ones to human review.
- Always include evidence in your pipeline so reviewers can verify data in seconds without rereading the whole document.
- Test with your hardest invoices first; scans and photos are the weak spots for any extraction API.
- The Free tier offers 50,000 credits, which is enough to test about 800 single-page invoices before committing.
The Bottom Line
Don't just OCR and pray. A schema-based API with evidence and confidence scores is the only way to build a trustworthy, automated accounts payable workflow that scales.