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/getineocr

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/getineocr" \
  -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 StatusCode 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. 400 Invalid document type
INOCR005 The uploaded file exceeds the maximum allowed size of 5MB. 400 File size exceeds 5MB limit
INOCR006 There was an error decoding the JSON input. 400 JSON decoding error
INOCR007 An error occurred while calling the Textract service. 502 External OCR service error
INOCR008 The provided image cannot be null or empty. 400 Image is null or empty
INOCR009 An error occurred while decoding the Textract response. 502 Error decoding OCR service response
INOCR010 An error occurred while calling the NLP service. 502 External NLP service error
INOCR011 The NLP service returned a null or empty response. 502 NLP service returned empty response
INOCR012 The extracted text from both sides of the document is empty. 400 No text could be extracted from the images
INOCR013 Failed to parse the structured data from the NLP service response. 502 Error parsing NLP response
INOCR014 Invalid image format. Only JPG, JPEG, and PNG formats are supported. 400 Unsupported image format
INOCR015 Failed to process the uploaded image file. 400 Image processing failed
INOCR016 The apiKey is not valid. 401 The apiKey is not valid.