/ocr/idcard - 身份证识别接口

1.API 说明
2.请求参数
3.响应参数
4.错误码
5.示例

1.API 说明

该 API 用于识别秘鲁身份证并提取关键信息。

图片规格

1. 格式:JPG(JPEG)、PNG、e-aadhaar(PDF)
2. 像素范围:128*128 到 6000*6000,推荐分辨率为 1280*1280
3. 文件大小不得超过 5MB

请求方法

POST

请求地址

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

Debugging Tool

Debugging Tool

2.请求参数

2.1 请求头

参数 类型 是否必填 描述
X-DF-API-ID string Yes API 认证信息请参见 API 请求
X-DF-API-SECRET string Yes API 认证信息请参见 API 请求

2.2 请求体

Fields 类型 描述
optional file file 图像的二进制数据
optional image_base64 string 图像的 Base64 编码数据
optional detect_face integer 1: 启用人脸检测,返回 face_region 字段; 0: 默认值,关闭人脸检测.

Either parameter file or image_base64 必须提供作为请求参数.

使用 file 参数时,必须将图像流添加到 POST 请求的 multipart/form-data 部分。

3.响应参数

Fields 类型 描述
request_id string 每个请求的唯一 ID
status string 响应状态:OK 表示成功,失败请参考错误码
results array 身份证识别结果数组,详见下方 results 字段
results中的字段:
Fields 类型 描述
card_type string 卡片类型:old(旧版)/ new(新版)/ ALIEN(外籍)
card_side string 卡片正反面:front 表示正面
card_info object 卡片的关键信息
face_region array 人脸区域四个点坐标,格式为: [(x1, y1), (x2, y2), (x3, y3), (x4, y4)]; 坐标基于原始图像, while 坐标顺序为旋转后人脸的:左上、右上、右下、左下.
card_info中的字段
  • 新ID卡正面
Fields 类型 描述
id_number string ID卡号
father_name string 父亲姓名
mother_name string 母亲姓名
name string 姓名
gender string 性别(西班牙语),MASCULINO:男,FEMENINO:女
gender_s string 格式化后的性别,M:男,F:女
marriage string 婚姻状态(西班牙语),Soltero:单身,Casado:已婚,Divorciado:离婚,Viudo:丧偶
birthday string 出生日期
birth_place string 出生地
issue_date string 签发日期
expiry_date string 到期日期
election_number string 选民号
organ_donation string 器官捐献,SI:是,No:否
  • 新ID卡背面
Fields 类型 描述
region string 大区/省/区
address string 详细地址
  • 旧版ID卡正面
Fields 类型 描述
id_number string ID卡号
father_name string 父亲姓名
mother_name string 母亲姓名
name string 姓名
gender string 性别,M:男,F:女
gender_s string 性别,M:男,F:女
marriage string 婚姻状态,S:单身,C:已婚,D:离婚,V:丧偶
birthday string 出生日期
birth_place string 出生地
registration_date string 登记日期
issue_date string 签发日期
expiry_date string 到期日期
  • 旧版ID卡背面
Fields 类型 描述
department string 大区
province string
district string
address string 详细地址
election_number string 选民号
organ_donation string 器官捐献,SI:是,No:否
  • 外国人卡正面
Fields 类型 描述
id_number string ID卡号
document_number string 证件号码
surname string 姓氏
given_name string 名字
gender string 性别
gender_s string 格式化后的性别,M:男,F:女
marriage string 婚姻状态,S:单身,C:已婚,D:离婚,V:丧偶
birthday string 出生日期
birthday_s string 格式化出生日期
issue_date string 签发日期
issue_date_s string 格式化签发日期
expiry_date string 到期日期
expiry_date_s string 格式化到期日期
nationality string 国籍
migratory_quality string 移民类别

返回示例
  • 新ID卡正面
{
  "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
    ]
  ]
]
}
  • 新ID卡背面
{
  "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"
  }]
}
  • 旧卡正面
{
  "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
      ]
    ]
]
}
  • 旧卡背面
{
  "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"
}
  • 外国人卡正面
{
    "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.错误码

常见错误码如下:

HTTP 状态码 Status field 描述
400 INVALID_ARGUMENT 请求参数无效
400 DETECTION_FAILED 图像检测失败
401 UNAUTHORIZED 未授权或无访问权限
401 KEY_EXPIRED API ID 已过期
403 NO_PERMISSION 您无权限使用该接口
403 OUT_OF_QUOTA API 调用次数超限
403 RATE_LIMIT_EXCEEDED 请求频率超限
404 NOT_FOUND 接口不存在
500 INTERNAL_ERROR 服务器内部错误

说明: 当出现 40X 错误时,请查看响应中的 reason 字段以获取详细信息。

错误返回示例:
{
  "status": "INVALID_ARGUMENT",
  "reason": "must specify 'file' or 'image_base64' argument",
  "request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e"
}

5.Sample

results matching ""

    No results matching ""