Extract data from a document: invoice, receipt, contract fields as JSON
No account. Pay by card from $1 and your key appears right after payment. Get a key by card
Invoice data extraction API: code samples in curl, Python and Node, and monthly plans.
Extract named fields from a document as JSON: give a PDF, Word, Excel or PowerPoint file, a scan or a photo (PNG, JPEG, WebP) by URL or in a POST body (up to 10 MB; images 3 MB) and the field names you want, such as invoice_number, total, due_date. An AI model reads the file, scans by OCR, and returns one JSON object, with null where a value is not stated. Use to turn invoices, receipts, orders and contracts into rows.
Inputs
| Name | Type | Description |
|---|---|---|
url (required) | string | Absolute public http(s) URL of the file (or send the file in a POST body instead). With no input at all (no URL) this reads the public sample invoice PDF in the example and the answer says so. |
fields (required) | string | Comma-separated field names to extract (1-30). For rows, give the row keys in brackets: line_items[description,quantity,amount]. Or one word, invoice or receipt, for the usual fields of that document with its line items |
Request
Over HTTP, with a card key from /credits:
curl -H "Authorization: Bearer adt_…" "https://glyphtools.com/document/extract?url=https%3A%2F%2Fraw.githubusercontent.com%2Finvoice-x%2Finvoice2data%2Fmaster%2Ftests%2Fcompare%2Fcoolblue1.pdf&fields=invoice"
Node.js
const r = await fetch("https://glyphtools.com/document/extract?url=https%3A%2F%2Fraw.githubusercontent.com%2Finvoice-x%2Finvoice2data%2Fmaster%2Ftests%2Fcompare%2Fcoolblue1.pdf&fields=invoice", {
headers: { Authorization: "Bearer adt_…" },
});
const data = await r.json(); // 402 until the key is in the header
Python
import requests
r = requests.get("https://glyphtools.com/document/extract?url=https%3A%2F%2Fraw.githubusercontent.com%2Finvoice-x%2Finvoice2data%2Fmaster%2Ftests%2Fcompare%2Fcoolblue1.pdf&fields=invoice", headers={"Authorization": "Bearer adt_…"}, timeout=60)
data = r.json()
Without a key, the same URL answers 402 Payment Required with x402 and MPP terms, so an agent with a wallet pays per call in USDC (Base, Polygon, Arbitrum or Solana over x402; Base or Tempo over MPP) and retries.
Example result
{
"url": "https://raw.githubusercontent.com/invoice-x/invoice2data/master/tests/compare/coolblue1.pdf",
"type": "pdf",
"data": {
"supplier_name": "Coolblue B.V.",
"supplier_vat_number": "NL810433941B01",
"supplier_address": "Weena 664\n3012 CN Rotterdam\nNederland",
"customer_name": "Pino Bluebird",
"customer_vat_number": null,
"invoice_number": "993548900",
"invoice_date": "2014-04-19",
"due_date": null,
"currency": "EUR",
"subtotal": 593.36,
"tax_amount": 124.61,
"total": 717.97,
"iban": "NL50INGB0683251309",
"payment_reference": null,
"line_items": [
{
"description": "Apple iPad Air Wifi 16 GB Zilver",
"quantity": 1,
"unit_price": 399,
"amount": 399
},
{
"description": "Decoded Leather Slim Cover Apple iPad Air 2 Zwart",
"quantity": 1,
"unit_price": 69.99,
"amount": 69.99
},
{
"description": "Nintendo 3DS XL Wit + Blauw",
"quantity": 1,
"unit_price": 189,
"amount": 189
},
{
"description": "Nintendo AC-adapter",
"quantity": 1,
"unit_price": 14.99,
"amount": 14.99
},
{
"description": "Mario Kart 7 3DS",
"quantity": 1,
"unit_price": 44.99,
"amount": 44.99
}
]
},
"missing": [
"customer_vat_number",
"due_date",
"payment_reference"
],
"model": "@cf/openai/gpt-oss-120b",
"charsRead": 1069,
"truncated": false
}
From an AI agent (MCP)
Add the MCP server to Claude, Cursor or any MCP client. This tool is document_extract, paid from the first call:
https://glyphtools.com/mcp