ID Reader
POSThttps://api.apptenticate.com/api/v2/ocr/
Authentication
Use your JWT obtained from the authentication process to make requests to this endpoint.
The response will be 401 unauthorized if the JWT is expired. In this case you will have to obtain a new JWT.
This endpoint receives all requests directed to the Apptenticate OCR microservice that allows data to be extracted from identification documents. In this case, it is possible to process passports that contain MRZ (Machine Readable Zone) and Panamanian ID cards with or without QR code. These requests must specify the type of document to be processed, an image of the front of the document and an image of the back (in the case of identity cards). In the end, the ID Reader microservice will return a JSON with the extracted data if the operation was successful, or the appropriate error if it was not.
NOTE
• The response may be 401 unauthorized if the JWT token must be refreshed.
• Images sent in jpg format must not exceed 2MB.
• If you want to obtain the transaction ID in the response, you must indicate "return_id": "True" in the JSON of the request.
• It must be specified in the request whether a photo of a passport or ID is sent using the “document_type” parameter, which can take the values “passport” or “identification_card”.
Request structure - method: POST
• Payload for base request:
Payload: {
'frontside': Image of the front of the document,
'backside': Image of the back of the document,
'document_type': 'passport' or 'identification_card',
} // (where images are .jpg files)
• If you want to obtain the transaction ID:
Payload: {
'frontside': Image of the front of the document,
'backside': Image of the back of the document,
'document_type': 'passport' or 'identification_card',
'return_id':True
} // (where images are .jpg files)
• If you want to improve the precision of the life test
Payload: {
'frontside': Image of the front of the document,
'backside': Image of the back of the document,
'document_type': 'passport' or 'identification_card',
'device':'IOS', // Devices: IOS, ANDROID or DESKTOP
} // (where images are .jpg files)
Examples of requests
#JWTToken
header = { 'Authorization': 'Bearer {}'.format(token) }
# Payload for base request
data = {'document_type': 'passport'}
files = {
'frontside': image_1.jpg,
'backside': image_2.jpg,
} # Where images are .jpg files
# If you want to obtain the transaction ID:
data = {'document_type': 'passport', 'return_id': True}
files = {
'frontside': image_1.jpg,
'backside': image_2.jpg,
} # Where images are .jpg files
# Send request
response = requests.post(
apptenticate_url,
data=data,
files=files,
headers=header
)
response = json.loads(response.content)
Response structure
If the request is successful and the document is processed correctly, a JSON of the form is returned:
• Transaction ID response for (Panamanian ID card):
{
"document_number": "E-8-123456",
"names": "Sofia Maria",
"surnames": "Lopez Contreras",
"gender": "F",
"birth_country": "VENEZUELA",
"birth_date": "10-10-1994",
"nationality": "VENEZOLANA",
"issuing_date": "12-08-2022",
"expiration_date": "12-08-2032",
"valid": true,
"id": 281234
}
• Transaction ID response for (passport):
{
"document_number": "AN123456",
"registry_number": "CC0123456789",
"country": "COL",
"names": "JULIAN ANDRES",
"surnames": "PEREZ GARCIA",
"birth_date": "02-05-94",
"gender": "M",
"expiration_date": "30-07-22",
"image_score": 100,
"valid": true,
"id": 281234
}
• Error response:
{
"error": "No se pudo hacer OCR del documento",
"error_code": 806,
"details": {
"metadata": "No se pudo procesar correctamente alguno de los datos del documento"
}
}
ID Reader
Passports OCR:
| Codigo | Mensaje |
|---|---|
800 | The archive couldn't be processed. |
801 | MRZ couldn't be extracted. |
802 | Couldn't process birthdate. |
803 | Couldn't process gender. |
804 | Couldn't process expiration date. |
ID Cards OCR:
| Codigo | Mensaje |
|---|---|
805 | Error processing QR. |
806 | Couldn't extract document metadata. |
807 | Couldn't extract names on document. |
808 | Couldn't extract ID number. |
809 | "Frontside" request not sent. |
810 | "Backside" not sent. |