/ocr/idcard

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

1. 接口规范

该接口用于识别尼日利亚身份证,并提取关键信息。

图片要求

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

请求方式

POST

请求地址

https://cloudapi.nigeria.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 的 POST 请求中。

3. 返回参数

字段 类型 描述
request_id string 请求唯一 ID
status string 返回状态,成功为 OK,否则失败,详见 错误码
results array 身份证识别结果,详见下文
results 字段结构说明:
字段 类型 描述
card_side string 卡片面,固定为 front
card_info object 卡片关键信息
face_region array 人脸区域的四点坐标,格式为:[(x1, y1), (x2, y2), (x3, y3), (x4, y4)];坐标基于原图,点顺序为旋转后顺序:左上、右上、右下、左下
card_info 字段说明:
字段 类型 描述
id_number string 身份证号码
first_name string
middle_name string 中间名
surname string
birthday string 出生日期(如:03 MAY 1967)
birthday_s string 出生日期格式化(dd-mm-yyyy)
gender string 性别,MF
height string 身高(如:180CM)
issue_date string 发证日期(如:21 MAY 2014)
issue_date_s string 发证日期格式化(dd-mm-yyyy)
expiry_date string 到期日期(如:05/24)
expiry_date_s string 到期日期格式化(dd-mm-yyyy)
nationality string 国籍
document_number string 文档编号

返回示例:
{
    "request_id": "TIDe32de81c8a194ee9bca6c5de00ca338a",
    "results": [
        {
            "card_info": {
                "id_number": "5412 7512 3412****",
                "birthday": "03 MAY 1967",
                "birthday_s": "03-05-1967",
                "document_number": "541275****",
                "expiry_date": "05/24",
                "expiry_date_s": "01-05-2024",
                "first_name": "AMXXX",
                "gender": "M",
                "height": "180CM",
                "issue_date": "21 MAY 2014",
                "issue_date_s": "21-05-2014",
                "middle_name": "AYOXXX",
                "nationality": "NGA",
                "surname": "AHMED"
            },
            "card_side": "front",
            "face_region": [
                [325, 1010],
                [736, 1010],
                [736, 1523],
                [325, 1523]
            ]
        }
    ],
    "status": "OK"
}

4. 错误码

常见错误码如下:

HTTP 状态码 status 字段 描述
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 ""