/ocr/idcard
1. 接口说明
2. 请求参数
3. 返回参数
4. 错误码
5. 示例
1. 接口说明
本接口用于识别加纳身份证,提取关键信息。
图片要求
- 格式:JPG(JPEG)、PNG、e-aadhaar(PDF)
- 尺寸:128×128 至 6000×6000 像素,推荐分辨率:1280×1280
- 文件大小:不超过 5MB
请求方式
POST
请求地址
https://cloudapi.ghana.accuauth.com/ocr/idcard
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 编码字符串 |
file
或image_base64
必须至少提供一个参数。若使用
file
参数,必须将图片数据作为 multipart/form-data 上传。
3. 返回参数
字段名 | 类型 | 描述 |
---|---|---|
request_id | string | 每次请求的唯一 ID |
status | string | 返回状态,成功为 OK ,失败为其他值;详细见错误码 |
results | array | 卡证识别结果数组,详见下方 results 内容 |
results
中的元素:
字段名 | 类型 | 描述 |
---|---|---|
card_type | string | 卡片类型:ID (身份证)或 VOTER (选民卡) |
card_side | string | 卡片面:目前为 front |
card_info | object | 识别出的证件关键信息 |
card_info
内容(身份证正面):
字段名 | 类型 | 描述 |
---|---|---|
id_number | string | 身份证号码 |
document_number | string | 证件编号 |
first_name | string | 名 |
middle_name | string | 中间名 |
surname | string | 姓 |
previous_name | string | 曾用名 |
birthday | string | 出生日期(原始格式) |
birthday_s | string | 出生日期(dd-mm-yyyy 格式) |
gender | string | 性别,M 男,F 女 |
height | string | 身高 |
issue_date | string | 发证日期(原始格式) |
issue_date_s | string | 发证日期(dd-mm-yyyy 格式) |
expiry_date | string | 到期日期 |
expiry_date_s | string | 到期日期(dd-mm-yyyy 格式) |
place_of_issue | string | 签发地 |
nationality | string | 国籍 |
card_info
内容(选民卡正面):
字段名 | 类型 | 描述 |
---|---|---|
voter_id_number | string | 选民卡号码 |
surname | string | 姓 |
other_names | string | 名字(不含姓) |
age | string | 年龄 |
gender | string | 性别,M 男,F 女 |
birthday | string | 出生日期 |
birthday_s | string | 出生日期(dd-mm-yyyy) |
registry_date | string | 登记日期 |
registry_date_s | string | 登记日期(dd-mm-yyyy) |
polling_station_code | string | 投票站编号 |
返回示例(身份证):
{
"request_id": "TID3e16f795acf14c50805693c39fe84993",
"results": [
{
"card_info": {
"id_number": "GHA-72126****-2",
"document_number": "AM309****",
"first_name": "FELAX",
"middle_name": "",
"surname": "ADJOL",
"previous_name": "",
"birthday": "10/05/1984",
"birthday_s": "10-05-1984",
"gender": "M",
"height": "1.67",
"issue_date": "0403/2020",
"issue_date_s": "04-03-2020",
"expiry_date": "03/03/2030",
"expiry_date_s": "03-03-2030",
"place_of_issue": "ACCRA",
"nationality": "GHANAIAN"
},
"card_side": "front",
"card_type": "ID"
}
],
"status": "OK"
}
返回示例(选民卡):
{
"request_id": "TID21afee54bdda4b76b9593222db2c6dee",
"results": [
{
"card_info": {
"birthday": "",
"birthday_s": "",
"age": "18",
"gender": "M",
"other_names": "DOM***",
"polling_station_code": "C110XXX",
"registry_date": "2020/06/30",
"registry_date_s": "30-06-2020",
"surname": "BRITWUM",
"voter_id_number": "439300xxxx"
},
"card_side": "front",
"card_type": "VOTER"
}
],
"status": "OK"
}
4. 错误码
常见错误码如下:
HTTP 状态码 | status 字段 |
描述 |
---|---|---|
400 |
INVALID_ARGUMENT | 请求参数无效 |
400 |
DETECTION_FAILED | 图像检测失败 |
401 |
UNAUTHORIZED | 未授权或访问被拒绝 |
401 |
KEY_EXPIRED | API 密钥已过期 |
403 |
NO_PERMISSION | 无权使用该接口 |
403 |
OUT_OF_QUOTA | 接口调用次数已用完 |
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"
}