/ocr/idcard

1. 接口规范
2. 请求参数
3. 返回参数
4. 错误码
5. 示例

1. 接口规范

该接口用于识别墨西哥身份证(INE/IFE),并提取关键信息。

图片要求

  1. 格式:JPG(JPEG)、PNG、e-aadhaar(PDF)
  2. 尺寸:128×128 至 6000×6000 像素,推荐分辨率:1280×1280
  3. 文件大小:不超过 5 MB

请求方式

POST

请求地址

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

Debugging Tool

Debugging Tool

2. 请求参数

2.1 请求头

参数 类型 是否必填 描述
X-DF-API-ID string API 凭证,请访问 API Request
X-DF-API-SECRET string API 凭证,请访问 API Request

2.2 请求体

可选 字段 类型 描述
可选 file file 图像二进制数据
可选 image_base64 string 图像的 Base64 编码
可选 detect_face integer 是否启用人脸检测。1:启用并返回 face_region 字段,0:默认关闭

fileimage_base64 参数必须至少提供一个。

使用 file 参数时,需将图像数据添加至 multipart/form-data 部分。

3. 返回参数

字段 类型 描述
request_id string 请求的唯一 ID
status string 响应状态,成功为 OK,否则失败;详情见 错误码
results array OCR 识别结果数组,详见下方字段说明
results 数组字段说明:
字段 类型 描述
card_side string 身份证的面:frontback
card_type string 卡片类型:CDEDE
card_info object 卡片关键信息
face_region array 人脸区域的四点坐标,格式为 [(x1, y1), (x2, y2), (x3, y3), (x4, y4)],坐标基于原图,点序为旋转后的人脸区域(左上、右上、右下、左下)
card_info 字段说明:

字段 类型 描述
**id_number** *string* 身份证号码
**voter_id** *string* 选民 ID
**name** *string* 姓名
**full_name** *string* 全名
**birthday** *string* 出生日期,格式:dd/mm/yyyy
**gender** *string* 性别,`H` = 男,`M` = 女
**gender_s** *string* 格式化性别,`M` = 男,`F` = 女
**address** *string* 地址信息
**state** *string* 所在州
**district** *string*
**sub_district** *string* 街道/小区
**postal_code** *string* 邮政编码
**registration_year_and_month** *string* 注册年月
**state_number** *string* 州编号
**municipal_number** *string* 市政编号
**election_section_number** *string* 选区编号
**place_number** *string* 投票点编号
**issue_year** *string* 发证年份
**expiry_year** *string* 到期年份
**invoice** *string* 发票编号
**father_last_name** *string* 父姓
**mother_last_name** *string* 母姓
正面返回示例:
{
  "request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e",
  "status": "OK",
  "results": [{
     "card_side": "front",
     "card_type": "C",
     "card_info": {
       ...
     },
     "face_region": [
       [325, 1010],
       [736, 1010],
       [736, 1523],
       [325, 1523]
     ]
  }]
}
字段 类型 描述
**line1_all** *string* 第一行内容
**line2_all** *string* 第二行内容
**line3_all** *string* 第三行内容
**line1_and_line2_verification_code** *string* 第一和第二行的校验码
**cic** *string* CIC 编码
**cic_verification_code** *string* CIC 校验码
**ocr** *string* OCR 编码
**birthday** *string* 出生日期(yymmdd)
**gender** *string* 性别,`H` = 男,`M` = 女
**gender_s** *string* 格式化性别,`M` = 男,`F` = 女
**expiry_date** *string* 到期日期
**expiry_date_verification_code** *string* 到期校验码
**nationality** *string* 国籍
**issuance_and_fuar** *string* 签发及 FUAR 编号
**father_last_name** *string* 父姓
**mother_last_name** *string* 母姓
**name** *string* 名字
背面返回示例:
{
  "request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e",
  "status": "OK",
  "results": [{
     "card_side": "back",
     "card_type": "DE",
     "card_info": {
       ...
     }
  }]
}

4. 错误码

常见错误码如下:

HTTP 状态码 status 字段 描述
400 INVALID_ARGUMENT 请求参数无效
400 DETECTION_FAILED 图像识别失败
401 UNAUTHORIZED 未授权或访问被拒绝
401 KEY_EXPIRED API ID 已过期
403 NO_PERMISSION 无权限使用该接口
403 OUT_OF_QUOTA 超出调用配额
403 RATE_LIMIT_EXCEEDED 调用频率超过限制
404 NOT_FOUND 未找到 API
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 ""