/ocr/idcard

1.API Specification
2.Request Params
3.Response Params
4.Error Codes
5.Sample

1.API Specification

This API is used to recognize ID card of Mexico, and extract the key information.

Image spec

1. Format: JPG(JPEG), PNG, e-aadhaar(PDF)
2. Between 128*128 and 6000*6000 (pixels), Recommended resolution: 1280*1280
3. File size: no larger than 5 MB

Request Method

POST

Request URL

https://cloudapi.mexico.accuauth.com/ocr/idcard

Debugging Tool

Debugging Tool

2.Request Params

2.1 Request Header

Parameter Type Required Description
X-DF-API-ID string Yes For API credentials,Please visit API Request
X-DF-API-SECRET string Yes For API credentials,Please visit API Request

2.2 Request Body

Fields Type Description
optional file file Binary data of the image
optional image_base64 string Base64 encoded data of image
optional detect_face integer 1: enable face detection, and the face_region field will be returned; 0: the default value, disable face detection.

Either parameter file or image_base64 must be provided as a request parameter.

You MUST add image stream to multipart/form-data section of POST message when using file parameter.

3.Response Params

Fields Type Description
request_id string Unique id of each request
status string Response status, OK if request success, other if failed; See Error Codes for details
results array The array of card ocr results,See results belowed for details
Elements in results:
Fields Type Description
card_side string The side of ID card: front or back
card_type string One of the card Type: CDE or DE
card_info object The key infomation of card
face_region array Four point coordinates of face rect, format as: [(x1, y1), (x2, y2), (x3, y3), (x4, y4)]; The coordinate is based on the original image, while the points order is based on the face after rotation(top left, top right, bottom right, bottom left).
Elements in the card_info
  • Front side of INE/IFE card info:
Fields Type Description
id_number string ID card number
voter_id string Voter ID
name string Name
full_name string Full name
birthday string Date of birth, format: dd/mm/yyyy
gender string Gender, H = MALE or M = FEMALE
gender_s string Formatted gender, M = MALE or F = FEMALE
address string Address detail
state string State in the address
district string District in the address
sub_district string Sub-district in the address
postal_code string Pin code in the address
registration_year_and_month string Registration year and month of the card
state_number string Number of the state
municipal_number string Number of the municipal government
election_section_number string Number of the election section
place_number string Number of the place
issue_year string Issue year of the card
expiry_year string Expiry year of the card
invoice string Invoice number
father_last_name string Last name of the father
mother_last_name string Last name of the mother
  • Back side of INE/IFE card info:
Fields Type Description
line1_all string Line1 detail information
line2_all string Line 2 detail information
line3_all string Line 3 detail information
line1_and_line2_verification_code string Line 1 and line 2 verification code
cic string Cic of the person
cic_verification_code string Cic verification code of the card
ocr string OCR of the person
birthday string Date of birth, format: yymmdd
gender string Gender, H = MALE or M = FEMALE
gender_s string Formatted gender, M = MALE or F = FEMALE
expiry_date string Expiry date of the card
expiry_date_verification_code string Expiry date verification code
nationality string Nationality of the person
issuance_and_fuar string Issuance and fuar of the card
father_last_name string Last name of the father
mother_last_name string Last name of the mother
name string Name of the person

Response Syntax
  • Front side of INE/IFE card
{
  "request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e",
  "status": "OK",
  "results": [{
     "card_side": "front",
     "card_type": "C",
     "card_info":{
            "voter_id": ""xxxxxx,
            "id_number":"RU*************3",
            "birthday":"21/02/1984",
            "address_all":"C *************UC",
            "gender":"H",
            "gender_s":"M",
            "father_last_name":"RUBIO",
            "postal_code":"97960",
            "full_name":"R*************DO",
            "expiry_year":"2026",
            "registration_year_and_month":"200602",
            "place_number":"0001",
            "election_section_number":"0979",
            "issue_year":"2016",
            "state_number":"31",
            "district":"TZUCACAB",
            "mother_last_name":"VERDEJO",
            "name":"CA*************DO",
            "invoice":"",
            "state":"YUC",
            "sub_district":"COL CENTRO",
            "age":"",
            "municipal_number":"098"
      },
      "face_region": [
        [
            325,
            1010
        ],
        [
            736,
            1010
        ],
        [
            736,
            1523
        ],
        [
            325,
            1523
        ]
      ]
  }]
}
  • Back side of INE or IFE card
{
  "request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e",
  "status": "OK",
  "results": [{
     "card_side": "back",
     "card_type": "DE",
     "card_info":{
            "line1_all": "ID*************5<",
            "line2_all": "95*************<<<",
            "line3_all": "OL*************LE<",
            "cic": "14*************24",
            "cic_verification_code": "4",
            "ocr": "3*************5",
            "birthday": "950221",
            "gender": "H",
            "gender_s": "M",
            "expiry_date": "261231",
            "expiry_date_verification_code": "7",
            "nationality": "MEX",
            "issuance_and_fuar": "0104139",
            "line1_and_line2_verification_code": "",
            "father_last_name": "OLIVAS",
            "mother_last_name": "BARRAZA",
            "name": "WILBERTH ALE"
      }
  }]
}

4.Error Codes

Common error codes of this API:

Http Status Code Status field Description
400 INVALID_ARGUMENT Request parameter is invalid
400 DETECTION_FAILED Detect image failed
401 UNAUTHORIZED Unauthorized or access is denied
401 KEY_EXPIRED Your API ID has expired
403 NO_PERMISSION You are not authorized to use this API
403 OUT_OF_QUOTA API calls quota exceeded
403 RATE_LIMIT_EXCEEDED API request frequency exceeds the limit
404 NOT_FOUND Requested API cannot be found
500 INTERNAL_ERROR Internal server error

Comment: Please see the reason field for details when the above 40X error occurred

Response Syntax
{
  "status": "INVALID_ARGUMENT",
  "reason": "must specify 'file' or 'image_base64' argument",
  "request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e"
}

5.Sample

results matching ""

    No results matching ""