INE-OCR API

Web Service Description

Extraction of structured data from INE documents using OCR.

The service extracts and processes structured data from both sides (front and back) of Mexican INE (Instituto Nacional Electoral) identification cards, delivering a JSON response with the obtained data.

~/api/IneOcr

Parameters.

Tag Type Required Description
FrontImage file yes Front side image of INE document .jpg, .jpeg, *.png
BackImage file yes Back side image of INE document .jpg, .jpeg, *.png

Headers.

Tag Type Required Description
apikey string yes Customer key.

FormData.

{
  "FrontImage": "file",
  "BackImage": "file"
}

CURL

curl -X POST "~/api/IneOcr" \
  -H "accept: application/json" \
  -H "apikey: {YOUR_API_KEY}" \
  -H "Content-Type: multipart/form-data" \
  -F "FrontImage=@path_to_front_image" \
  -F "BackImage=@path_to_back_image"

Response.

Response:

Name Type Description
name string First name of the person
firstLastName string First last name (apellido paterno)
secondLastName string Second last name (apellido materno)
addressLine1 string Address line 1 (Street and number)
addressLine2 string Address line 2 (Colony/Neighborhood)
addressLine3 string Address line 3 (City, State, Postal Code)
electoralId string Electoral ID number (Clave de Elector)
issueNumber string Issue number of the INE card
curp string CURP (Clave Única de Registro de Población) - 18 characters
dateOfBirth string Date of birth in format DD/MM/YYYY or YYYY-MM-DD
sex string Sex - "H" for Masculino or "M" for Femenino
expirationDate string Expiration date of the INE card in format DD/MM/YYYY or YYYY-MM-DD
mz1 string Machine Readable Zone line 1 (starts with IDMEX)
mz2 string Machine Readable Zone line 2 (starts with date of birth YY/MM/DD)
mz3 string Machine Readable Zone line 3 (contains full name)
idMex string Extracted ID from MZ1 - 9 characters following "IDMEX" marker
idNumber string Extracted ID Number from MZ1 - 13 characters after the last "<<" marker

JSON.

{
  "name": "JUAN",
  "firstLastName": "PEREZ",
  "secondLastName": "GARCIA",
  "addressLine1": "CALLE REFORMA 123",
  "addressLine2": "COL. CENTRO",
  "addressLine3": "CIUDAD DE MEXICO, CDMX, 06000",
  "electoralId": "PRGRJN90010112H100",
  "issueNumber": "01",
  "curp": "PEGJ900101HDFRRN09",
  "dateOfBirth": "01/01/1990",
  "sex": "H",
  "expirationDate": "2030",
  "mz1": "IDMEX123456789<<<<<<<<<<<<<<<<<",
  "mz2": "9001011H30<<<<<<<<<<<<<<<<<09",
  "mz3": "PEREZ<<GARCIA<<JUAN<<<<<<<<<<<<",
  "idMex": "123456789",
  "idNumber": "1234567890123"
}

Service Messages.

Code Message HTTP Status Code Description
INOCR001 An unexpected error occurred. Please try again later. 500 Internal server error
INOCR002 The front side of the document is required. 400 Front image is missing or empty
INOCR003 The back side of the document is required. 400 Back image is missing or empty
INOCR004 The document type provided is invalid. Only image files are accepted. 415 Invalid document type
INOCR005 The uploaded file exceeds the maximum allowed size of 5MB. 413 File size exceeds 5MB limit
INOCR006 An error occurred to process the file 500 Problem with the models
INOCR009 An error occurred analyzing the file 502 Error decoding OCR service response
INOCR012 The extracted text from both sides of the document is empty. 400 No text could be extracted from the images
INOCR014 Invalid image format. Only JPG, JPEG, and PNG formats are supported. 415 Unsupported image format
INOCR015 Failed to process the uploaded image file. The document may not be a valid INE card. 400 Image processing failed
INOCR016 Failed to process the Front Image, The document may not be a valid INE card. 400 Failed to process the front side of the INE document.
INOCR017 Failed to process the Back Image, The document may not be a valid INE card. 400 Failed to process the back side of the INE document.