Skip to content

OCR API that returns fields, text and their source

Send a document to the ChatYourData OCR API and get structured JSON back, or the full text as Markdown. One API reads invoices, receipts, contracts and any document you describe with a schema.

Northfield Fasteners Ltd
14 Mill Lane, Leeds LS1 4AB, United Kingdom

Invoice NF-20418

Invoice date: 12 November 2026
Due date: 12 December 2026

Bill to: Example Workshop Inc.
220 Lake Street, Madison, WI 53703, USA

DescriptionQtyUnit priceAmount
Hex bolt M8 x 40, box of 1001218.50222.00
Lock washer M8, box of 500421.0084.00
Freight164.0064.00

Net: 370.00 GBP
VAT 0%: 0.00 GBP
Total due: 370.00 GBP

Foreign invoice

{
  "invoice_number": "NF-20418",
  "issue_date": "2026-11-12",
  "payment_due": "2026-12-12",
  "seller_name": "Northfield Fasteners Ltd",
  "seller_country": "GB",
  "seller_address": "14 Mill Lane, Leeds LS1 4AB, United Kingdom",
  "buyer_name": "Example Workshop Inc.",
  "currency": "GBP",
  "net_amount": 370,
  "vat_amount": 0,
  "gross_amount": 370,
  "vat_rate": "0%",
  "reverse_charge": false,
  "items": [
    {
      "description": "Hex bolt M8 x 40, box of 100",
      "quantity": 12,
      "unit_price": 18.5,
      "net_value": 222
    },
    {
      "description": "Lock washer M8, box of 500",
      "quantity": 4,
      "unit_price": 21,
      "net_value": 84
    },
    {
      "description": "Freight",
      "quantity": 1,
      "unit_price": 64,
      "net_value": 64
    }
  ]
}

A fictional document with the real result from our model. Select a field to see where it was read from. PDF, PNG, JPG or WEBP up to 10 MB, first three pages, five documents without an account. Files you do not move to an account are deleted after 7 days.

What the OCR API can do

All endpoints use one API key. The base address is https://api.chatyourdata.pl.

EndpointWhat it doesReturns
POST /v1/extractReads fields by document type, automatic detection or your schemaJSON fields
POST /v1/splitSplits a file with many documents and reads each oneOne result per document
POST /v1/classifyRecognizes the document typeType and confidence
POST /v1/ocrReads the whole text with layout and tablesMarkdown per page
POST /v1/extractions/{id}/feedbackAccepts corrected values used as examples laterUpdated result
GET /v1/usageShows the pages used this monthUsage and key limit

Waiting for the result or using a webhook

With the wait parameter the response can hold the connection for up to 50 seconds and return the finished result. Longer documents return status 202 and an address to check later.

You can also pass a callback_url. We sign each webhook with HMAC-SHA256 and retry up to six times if your server does not answer with a 2xx status.

Safe retries

Add an Idempotency-Key header to the request. If a network error makes your system send the same document again with that key, you get the existing extraction and the pages are not used twice.

What the confidence score means

Confidence is calculated from checks rather than reported by the model. A value found word for word in the document that passes validation gets 0.95. A value that could not be found literally gets 0.75, and each reported issue lowers it by 0.35.

First request to the OCR API

The example reads an invoice. Replace the document type with “auto” to let the API recognize the document.

Request
curl https://api.chatyourdata.pl/v1/extract \
  -H "X-Api-Key: $CYD_KEY" \
  -F [email protected] \
  -F document_type=foreign_invoice \
  -F wait=30
Response (shortened)
{
  "data": {
    "id": "ext_812",
    "status": "done",
    "document_type": "foreign_invoice",
    "fields": {
      "invoice_number": { "value": "INV-2026-0042", "confidence": 0.95,
                          "page": 1, "source": "invoice no. inv-2026-0042" },
      "gross_amount":   { "value": 1000.0, "confidence": 0.95,
                          "page": 1, "source": "total due 1,000.00 eur" }
    },
    "issues": [],
    "usage": { "pages": 1 }
  }
}

Questions about OCR API

What is the maximum file size?

Files can be up to 25 MB. Larger files return status 413.

Can I limit the cost of one API key?

Yes. Each key can have its own monthly page limit, after which requests return status 429.

Are API files visible in document chat?

No. Files sent through the API are stored separately and are not used in chat answers.

Is there an OpenAPI description?

Yes. The API has an interactive reference and an OpenAPI file that you can use to generate a client.

Get an API key and send a document

The trial includes 200 pages over 14 days, with no card required.