API Reference
The Digitalize Lab API provides face recognition and liveness detection capabilities via a simple REST interface. All endpoints accept multipart/form-data (file upload) or application/json (Base64 encoded) requests and return JSON responses.
Authentication
All API endpoints require a valid token passed in the X-API-Token header (or as a Bearer token in Authorization). Contact the admin to obtain a token.
Error responses
Error Handling
All responses use HTTP 200 with a JSON body. Check the data.result field for error messages when image loading fails.
Compare Face
Compares two face images and returns whether they belong to the same person, along with a similarity score and face bounding boxes.
Request — Form Fields
| Field | Type | Required | Description |
|---|---|---|---|
| image1 | file | required | First face image |
| image2 | file | required | Second face image to compare against |
Response Fields
- data.resultstring"matched" | "not matched" | error message
- data.similarityfloatCosine similarity score, 0.0–1.0. Threshold: 0.67
- data.image1.detectionobjectBounding box {x, y, width, height} of face in image1
- data.image2.detectionobjectBounding box {x, y, width, height} of face in image2
- data.image1.featurestring512-dimensional face embedding vector (JSON array)
Compare Face — Base64
Same as /api/compare_face but accepts Base64-encoded images in a JSON body. Useful for mobile apps and web clients.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| image1 | string | required | Base64-encoded image (no data URI prefix) |
| image2 | string | required | Base64-encoded image (no data URI prefix) |
/api/compare_face.Check Liveness
Determines whether a face in an image is from a real live person or a spoof attempt (printed photo, screen replay, mask).
Request — Form Fields
| Field | Type | Required | Description |
|---|---|---|---|
| image | file | required | Face image to check |
Response Fields
- data.resultstring"real" | "spoof" | error message
- data.liveness_scorefloatScore 0.0–1.0. Above 0.5 = real. Below = spoof
- data.face_rectobjectFace bounding box {x, y, w, h}
- data.angles.yawfloatHead yaw angle in degrees
- data.angles.rollfloatHead roll angle in degrees
- data.angles.pitchfloatHead pitch angle in degrees
Check Liveness — Base64
Same as /api/check_liveness but accepts a Base64-encoded image in a JSON body.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| image | string | required | Base64-encoded image |
/api/check_liveness.Verify Document
Processes an ID document image and extracts all available information: structured fields, MRZ data, barcodes, and the holder's portrait photo.
Supports 14,000+ document types from 250+ countries including national ID cards, passports, driver licenses, and residence permits.
Request — Form Fields
| Field | Type | Required | Description |
|---|---|---|---|
| image | file | required | Document image (flat scan or photo) |
Response Fields
- data.errorCodeint0 = success; non-zero = processing error
- data.documentNamestringDetected document type, e.g. "France - Id Card (2021)"
- data.scorefloatDetection confidence 0.0–1.0
- data.image.documentFrontSidestringBase64-encoded JPEG of the annotated document
- data.image.portraitstringBase64-encoded JPEG of the extracted holder portrait
- data.mrzobjectParsed MRZ data — see sub-fields below
- data.mrz.namestringFull name
- data.mrz.surnamestringSurname / family name
- data.mrz.givenNamesstringGiven names
- data.mrz.documentNumberstringDocument number
- data.mrz.documentClassCodestringDocument class, e.g. "PC" (passport), "ID"
- data.mrz.dateOfBirthstringDate of birth (YYYY-MM-DD)
- data.mrz.dateOfExpirystringExpiry date (YYYY-MM-DD)
- data.mrz.nationalitystringNationality (full name)
- data.mrz.issuingStateCodestring3-letter issuing country code (ISO 3166-1 alpha-3)
- data.mrz.sexstring"M" | "F"
- data.mrz.mrzCodestringRaw MRZ lines joined with "^"
- data.mrz.validStateintMRZ checksum validity: 1 = valid
- data.ocrobjectVisual OCR fields (name, surname, dateOfBirth, etc.) — present for ID cards with VIZ zone
- data.barcodeobjectBarcode/PDF417 parsed fields — present when barcode is found
- data.portrait_rectobjectPortrait bounding box in original image {top, left, right, bottom}
- data.positionobjectDocument bounding box in original image {top, left, right, bottom}
Verify Document — Base64
Same as /api/verify_document but accepts a Base64-encoded image in a JSON body.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| image | string | required | Base64-encoded document image |
/api/verify_document.Health Check
Returns the current system status and engine version.
Changelog
- Added — Passive liveness detection endpoint (
POST /api/check_liveness) with neural-network anti-spoofing. Returns liveness score, bounding box, and head-pose angles (yaw / roll / pitch). - Added — Base64 variants for all endpoints (
/api/compare_face_base64,/api/check_liveness_base64,/api/verify_document_base64) for browser and mobile clients. - Added — ID Document Verification (
POST /api/verify_document) supporting 14,000+ document types with full MRZ parsing, portrait extraction, barcode decoding, and structured field output. - Added —
GET /healthendpoint returning engine status and version. - Improved — Face comparison now returns per-image detection bounding boxes and a 512-dimensional feature vector alongside the similarity score.
- Improved — All API errors return structured JSON (
{"status":"error","message":"..."}) — no HTML error pages. - Changed — Similarity threshold raised to
0.67(from 0.60 in v1.x) for lower false-accept rate.
- Foundation — Face comparison API (
POST /api/compare_face) with cosine similarity scoring and bounding-box detection. - Foundation — Token-based authentication and per-key rate limiting.