On-premises REST API

Integration Guide

The service runs entirely on your own machine, by default on http://127.0.0.1:8000. No internet connection is required and no document data leaves the host.

POST /api/extract

Reads one document. Locates and straightens the card, identifies the document type, extracts the fields, crops the portrait photograph, and checks the result against the document’s own internal validation. Send it as multipart/form-data.

ParameterTypeRequiredDescription
file Multipart file Yes Scanned document as JPEG, PNG or PDF. 300 DPI or better is recommended.
Example request
curl -X POST http://127.0.0.1:8000/api/extract \
  -F "[email protected]"
200 — UK driving licence
{
  "doc_type": "driving_licence",
  "accept": true,
  "checks_passed": 6,
  "checks_total": 6,
  "fields": {
    "Surname": "TAYLOR",
    "Given Names": "ALEX JAMES",
    "Title": "MR",
    "Date of Birth": "01.01.1990",
    "Date of Issue": "01.01.2020",
    "Date of Expiry": "01.01.2030",
    "Document Number": "TAYLO901011AJ9AB",
    "Address": "1 EXAMPLE STREET, LONDON, E1 1AA",
    "Address Street": "1 EXAMPLE STREET",
    "Address City": "LONDON",
    "Address Postal Code": "E1 1AA",
    "DL Class": "AM/B/f/k/q",
    "Card issuance number": "01",
    "Place of Birth": "UNITED KINGDOM",
    "Authority": "DVLA"
  },
  "confidences": { "Surname": 0.99 },
  "face": "data:image/jpeg;base64,...",
  "ms": 1600
}
FieldDescription
doc_typeOne of driving_licence, passport, id_card or unknown.
acceptWhether the document passed its own validation. See below.
checks_passed / checks_totalHow many validation checks ran, and how many agreed.
fieldsThe extracted values. Keys not present on the document are omitted.
confidencesPer-field recognition confidence, 0 to 1.
faceCropped portrait photograph as a base64 data URL, or null.
msProcessing time in milliseconds.
The accept flag

Every document is checked against itself. A UK licence number encodes the holder’s own surname and date of birth, and the machine-readable zone on a passport or ID card carries check digits. No external lookup is involved.

ValueMeaningWhat to do
true The document’s own checks agree with what was read. Safe to store.
false The checks disagree with what was read. Route to a person before storing.
Passports and ID cards

These are read from the machine-readable zone — the two or three lines of monospaced text at the foot of the document. It is an international standard (ICAO 9303) carrying its own check digits, so the values below are verified character by character rather than merely recognised. doc_type is passport for a passport book and id_card for an ID card.

200 — passport
{
  "doc_type": "passport",
  "accept": true,
  "checks_passed": 5,
  "checks_total": 5,
  "fields": {
    "Surname": "ERIKSSON",
    "Given Names": "ANNA MARIA",
    "Full Name": "ERIKSSON ANNA MARIA",
    "Document Number": "L898902C3",
    "Personal Number": "ZE184226B",
    "Date of Birth": "1974-08-12",
    "Date of Expiry": "2012-04-15",
    "Sex": "F",
    "Nationality": "UTO",
    "Nationality Code": "UTO",
    "Issuing State Code": "UTO",
    "Document Class Code": "P"
  },
  "face": "data:image/jpeg;base64,...",
  "ms": 1500
}
FieldDescription
Surname, Given NamesAs printed in the machine-readable zone.
Full NameSurname followed by given names.
Document NumberPassport or card number.
Personal NumberNational identifier, where the issuing country prints one.
Date of Birth, Date of ExpiryISO format, YYYY-MM-DD.
SexM, F or X.
Nationality, Nationality CodeThree-letter country code, e.g. GBR.
Issuing State CodeThree-letter code of the issuing country.
Document Class CodeP for passport, ID for an identity card.

Date of issue, place of birth and issuing authority are not returned for these documents. They are not part of the machine-readable zone, so they cannot be read from it. Do not treat their absence as a failure.

Date formats differ by document

Dates are returned as they are carried on the document, so the format is not the same for every type. Parse according to doc_type.

DocumentFormatExample
Driving licenceDD.MM.YYYY01.01.1990
Passport, ID cardYYYY-MM-DD1974-08-12
Response codes
CodeMeaning
200Document processed.
400The upload could not be read as an image.
422The document could not be processed.
Error response
{ "error": "Could not read that image." }
GET /health

Liveness check. Returns 200 once the model is loaded and the service is ready.

{ "status": "ok" }
GET /docs

Interactive API reference, generated from the service itself. Requests can be sent directly from the browser.