Aller au contenu principal

vision API

HTTP API of the vision service (FastAPI, no OpenAPI file in the repository: the interactive docs are disabled). It is internal only: the gateway has no /v1/extract or /v1/detect route, so callers are other services on the internal network (http://vision:8090 in docker-compose.yml, bound to 127.0.0.1:8090 on the host).

Conventions​

TopicRule
AuthenticationX-Atl-Principal header: EdDSA token signed with the gateway key, iss=atl-gateway, aud=atl-internal, exp required, kind in user, api_key, service, non-empty sub. Services forward the caller principal or sign a service principal with PRINCIPAL_SIGNING_KEY. No permission check.
Request bodymultipart/form-data; total body at most MAX_UPLOAD_BYTES × MAX_QR_IMAGES + 64 KiB (default about 100 MiB), checked on Content-Length and while streaming
Imagesjpeg, png, webp, heic (detected by Pillow, not by the client content type), at most MAX_UPLOAD_BYTES (10 MiB) and MAX_IMAGE_PIXELS (40 M pixels) each; EXIF orientation is applied
ConcurrencyCPU work limited to MAX_CONCURRENCY (2) jobs per process; extra requests wait
ErrorsRFC 9457 application/problem+json: title, status, code, optional detail (never PII)
Privacyimages and results are neither stored nor logged

POST /v1/extract/identity​

Extracts first name, last name and birth date from a photo of a French CNI (2021+ model, TD1 MRZ) or an EPITA student card.

Request (multipart):

FieldTypeRequiredDescription
imagefileyesDocument photo
kindstringnoauto (default), fr_id_card, epita_card

With auto, the CNI pipeline runs first, then the EPITA card heuristics if no valid CNI was found. With fr_id_card the card pipeline never runs. With epita_card the CNI pipeline is skipped.

Response 200:

FieldTypeDescription
document_typestringfr_id_card, epita_card or unknown
first_namestring or nullGiven names (MRZ: space separated)
last_namestring or nullSurname
birth_datestring or nullYYYY-MM-DD
confidencenumberOverall confidence in [0, 1]
fields_confidenceobjectfirst_name, last_name, birth_date confidences in [0, 1]
warningsstring arrayCodes below

An unrecognised document is still a 200 with document_type: unknown. An MRZ that is not a French CNI also returns unknown, but with the fields read from the MRZ.

WarningMeaning
names_not_checksummedAlways set for a CNI: TD1 check digits do not cover names, the user must review them
mrz_check_digit_mismatchAt least one check digit failed (at least half passed)
document_expiredMRZ expiry date in the past
mrz_not_foundNo usable TD1 MRZ
mrz_not_fr_id_cardMRZ found but issuer is not FRA or code is not ID
fr_id_card_pre_2021_not_supportedOld two-line CNI MRZ detected
document_not_recognizedNeither a CNI nor an EPITA card
epita_keywords_not_foundkind=epita_card but no card keyword found
name_not_found, birth_date_not_foundEPITA card field missing

When the EPITA card pipeline runs, earlier CNI warnings are cleared.

{
"document_type": "fr_id_card",
"first_name": "MARIE ANNE",
"last_name": "DUPONT",
"birth_date": "2001-04-12",
"confidence": 0.968,
"fields_confidence": {"first_name": 0.91, "last_name": 0.91, "birth_date": 0.94},
"warnings": ["names_not_checksummed"]
}

POST /v1/detect/qr​

Detects QR codes (QR, Micro QR, rMQR) and Data Matrix codes in one or several photos.

Request (multipart): images, one file per part, repeated, 1 to MAX_QR_IMAGES (10).

Response 200: {"codes": [...]}, one entry per distinct (text, format) per image, in request order:

FieldTypeDescription
image_indexintegerPosition of the image in the request (from 0)
textstringDecoded content
formatstringzxing format name: QRCode, MicroQRCode, RMQRCode, DataMatrix

An image without code simply adds nothing; an invalid image fails the whole request.

Errors​

StatuscodeWhen
400empty_imageEmpty file
400invalid_imageImage cannot be decoded
400too_many_imagesMore than MAX_QR_IMAGES images
401unauthenticatedMissing or invalid principal token (WWW-Authenticate: Bearer)
404, 405not_found, method_not_allowedUnknown route or method
413payload_too_largeBody, image size or pixel count above the limits
415unsupported_media_typeNot jpeg, png, webp or heic
422validation_failedMissing image / images, invalid kind (detail lists the fields)
500internalUnexpected error
503ocr_unavailableTesseract failed or timed out (/v1/extract/identity)

Probes and metrics​

No authentication, not logged:

MethodPathResponse
GET/healthz{"status": "ok"}
GET/readyz{"status": "ready"}, or 503 unavailable when Tesseract cannot run
GET/metricsPrometheus text format