/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 Peru, 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.peru.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_type string The type of card: old/new/ALIEN
card_side string The side of card: front
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
  • The front side of new ID card
Fields Type Description
id_number string ID card number
father_name string Father's name
mother_name string Mother's name
name string Name of the person
gender string Gender in Spanish, MASCULINO: male, FEMENINO: female
gender_s string Formatted gender, M: male, F: female
marriage string Marriage status in Spanish, Soltero: single, Casado: marriaged, Divorciado: divoiced, Viudo: widowed
birthday string Date of birth
birth_place string Birth place of the person
issue_date string Issue date
expiry_date string Expiry date
election_number string Election number
organ_donation string Organ donation, SI: Yes, No: No
  • The back side of new ID card
Fields Type Description
region string Department/Province/District
address string Detail address
  • The front side of old ID card
Fields Type Description
id_number string ID card number
father_name string Father's name
mother_name string Mother's name
name string Name of the person
gender string Gender, M: male, F: female
gender_s string Gender, M: male, F: female
marriage string Marriage status, S: single, C: marriaged, D: divorced, V: widowed
birthday string Date of birth
birth_place string Birth place of the person
registration_date string Registration date
issue_date string Issue date
expiry_date string Expiry date
  • The back side of old ID card
Fields Type Description
department string Department
province string Province
district string District
address string Detail address
election_number string Election number
organ_donation string Organ donation
  • The front side of ALIEN ID card
Fields Type Description
id_number string ID card number
document_number string Document number
surname string Surname
given_name string Given name
gender string Gender
gender_s string Formatted gender, M: male, F: female
marriage string Marriage status, S: single, C: marriaged, D: divorced, V: widowed
birthday string Date of birth
birthday_s string Formatted date of birth
issue_date string Issue date
issue_date_s string Formatted issue date
expiry_date string Expiry date
expiry_date_s string Formatted expiry date
nationality string Nationality
migratory_quality string Migratory quality

Response Syntax
  • Front side of new ID card
{
  "request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e",
  "status": "OK",
  "results": [{
     "card_type": "new",
     "card_side": "front",
     "card_info":{
     "id_number": "1075xxxx-x",
     "father_name": "COMXX",
     "mother_name": "CCAXXXXX",
     "name": "ANA ISAXXX",
     "gender": "FEMENINO",
     "gender_s": "F",
     "marriage": "Soltero",
     "birthday": "16/05/1994",
     "birth_place": "140133",
     "issue_date": "11/10/2019",
     "expiry_date": "11/10/2024",
     "election_number": "053xxx",
     "organ_donation": "NO"
  },
  "face_region": [
    [
        325,
        1010
    ],
    [
        736,
        1010
    ],
    [
        736,
        1523
    ],
    [
        325,
        1523
    ]
  ]
]
}
  • Back side of new ID card
{
  "request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e",
  "status": "OK",
  "results": [{
     "card_type": "new",
     "card_side": "back",
     "card_info":{
       "region": "LIMA/LIMA/LA VICTORIA",
       "address": "15 DE JULIO 10XX DPTO.21X"
  }]
}
  • Front side of old ID card
{
  "request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e",
  "status": "OK",
  "results": [{
     "card_type": "old",
     "card_side": "front",
     "card_info":{
       "id_number": "1075xxxx-x",
       "father_name": "COMXX",
       "mother_name": "CCAXXXXX",
       "name": "ANA ISAXXX",
       "gender": "F",
       "marriage": "S",
       "birthday": "16/05/1994",
       "birth_place": "140133",
       "registration_date": "11/10/2016",
       "issue_date": "11/10/2019",
       "expiry_date": "11/10/2024",
    },
    "face_region": [
      [
        325,
        1010
      ],
      [
        736,
        1010
      ],
      [
        736,
        1523
      ],
      [
        325,
        1523
      ]
    ]
]
}
  • Back side of old ID card
{
  "request_id": "TIDcfa616942c0e4c4cb3870cfb9b1a94be",
  "results": [
    {
      "card_info": {
        "address": "AV. BRASIL xxxx",
        "department": "LIMA",
        "district": "JESUS MARIA",
        "election_number": "036xxx",
        "organ_donation": "NO",
        "province": "LIMA"
      },
      "card_side": "back",
      "card_type": "old"
    }
  ],
  "status": "OK"
}
  • Front side of ALIEN ID card
{
    "request_id": "TIDdcda3ce2753a4455b459b370d7768dd1",
    "results": [
        {
            "card_info": {
                "birthday": "xx MAR 1991",
                "birthday_s": "xx-03-1991",
                "document_number": "",
                "expiry_date": "",
                "expiry_date_s": "",
                "gender": "M",
                "gender_s": "M",
                "given_name": "ADRIAN XXXXXX",
                "id_number": "004599xxx",
                "issue_date": "",
                "issue_date_s": "",
                "marriage": "S",
                "migratory_quality": "ESP ESPECIAL",
                "nationality": "VENEZOLANA",
                "surname": "RIOS XXXXX"
            },
            "card_side": "front",
            "card_type": "ALIEN",
            "face_region": [
                [
                    325,
                    1010
                ],
                [
                    736,
                    1010
                ],
                [
                    736,
                    1523
                ],
                [
                    325,
                    1523
                ]
              ]
        }
    ],
    "status": "OK"
}

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 ""