Skip to main content

Overview

This cookbook shows how to extract structured data from invoices using the Aifano /extract endpoint. You’ll define a JSON schema for the data you need, and Aifano will extract it from any invoice format — PDF, scanned image, or digital document.

What You’ll Build

A script that:
  1. Uploads an invoice to Aifano
  2. Extracts vendor info, line items, totals, and payment terms
  3. Returns clean, structured JSON ready for your accounting system

Step 1: Define the Extraction Schema

Create a JSON schema that describes the data you want to extract:

Step 2: Extract Data from an Invoice

Step 4: Batch Processing Multiple Invoices

For processing multiple invoices, use async endpoints to maximize throughput:
Python

Tips

Add context like currency format, date format, or language to the system_prompt to improve extraction accuracy.
If you need to extract different fields from the same invoice, use jobid:// to skip re-parsing and save credits.
Not all invoices have every field. Check for null values in the response and handle them in your application logic.

Next Steps