OCR API

OCR API提供证件图片识别并返回相应的证件信息。

API 方式

Base URL

API

URL请求方式Content-Type输出格式字符集
api-base-url?partner_code=xxx&partner_key=xxxPOSTapplication/jsonJSONUTF-8
认证参数
字段类型含义建议备注
partner_codeString合作方标识必须由 TD 分配
partner_keyString合作方密钥必须由 TD 分配

请求参数

字段类型含义建议备注
imageString证件照片必须JPG、JPEG、PNG的base64编码图⽚字符流,图⽚不能超过3M
countryString国家必须国家,必填. 两位国家码,符合 ISO 3166 标准。目前支持:印尼(ID) , 巴基斯坦(PK)
optionsString其他额外返回值可选填入"en",巴基斯坦身份证以下字段将返回Urdu语的英文翻译结果:
1. NIC证件的name、father_name字段
2. NIC/CNIC证件的current_address_en、permanent_address_en字段
*备注:如果需要,请联系商务/运营单独开通该增强型配置。

响应参数

字段类型含义建议备注
codeIntegerAPI 状态码必须
messageString状态信息必须在 API 异常状态下会输出具体的异常原因
sequence_idString响应唯一码必须用于跟踪每次请求记录的唯一标识
resultString结果条件必须:接口成功,code为200时才返回枚举值:
成功:success
失败:fail
card_infoJSONObject身份证信息条件必须:result 为success 时则返回

支持证件类型

  • 印尼KTP
    字段字段类型描述
    nikStringID card
    nameStringName
    birthdayStringDate of birth
    birthplaceStringPlace of birth
    genderStringGender
    blood_typeStringBlood group
    addressStringAddress
    rt_rwStringRT/RW
    villageStringVillage
    streetStringStreet
    religionStringReligion
    marital_statusStringMarital status
    occupationStringCareer
    nationalityStringCountry of Citizenship
    expiry_dateStringValidity period
    issue_dateStringIssue date
    issue_locationStringIssue location
    provinceStringProvince of residence
  • 巴基斯坦身份证(正面/反面)
    字段类型描述CNIC OR NIC
    card_sideStringThe side of card: front
    id_numberStringID card numberCNIC/NIC
    expiry_dateStringExpiry date of the cardCNIC
    issue_dateStringIssue date of the cardCNIC
    nameStringName in English
    备注:如果NIC证件该字段需要英语翻译,请联系商务/运营单独开通该增强型配置。
    CNIC
    name_urduStringName in UrduCNIC/NIC
    birthdayStringDate of birthCNIC/NIC
    genderStringGenderCNIC/NIC
    father_nameStringFather's name in English
    备注:如果NIC证件该字段需要英语翻译,请联系商务/运营单独开通该增强型配置。
    CNIC/NIC
    father_name_urduStringFather's name in UrduCNIC/NIC
    identifierStringPersonal identifierNIC
    country_of_stayStringCountry of stayCNIC
    字段类型描述CNIC OR NIC
    card_sideStringThe side of card: back
    id_numberStringID card numberCNIC/NIC
    current_addressStringCurrent addressCNIC/NIC
    expiry_dateStringExpiry date of the cardNIC
    family_numberStringFamily numberNIC
    permanent_addressStringPermanent addressCNIC/NIC
    issue_dateStringIssue date of the cardNIC
    current_address_enStringEnglish translation of current address
    备注:如果需要,请联系商务/运营单独开通该增强型配置。
    CNIC/NIC
    permanent_address_enStringEnglish translation of current address
    备注:如果需要,请联系商务/运营单独开通该增强型配置。
    CNIC/NIC

API 状态码

CodeMessage描述
200Success调⽤成功
301Service not purchased未购买此服务
302Traffic blocked流量已被禁用
303Traffic insufficient流量不足
304Service expired服务已过期
305Daily maximum volume reached日流量已封顶
12601Detection failed没有识别到证件
12602Document detected as having bad quality识别到证件,但证件质量差
*只针对印尼OCR服务才有的错误码
11350Internal error系统错误
11301{parameter} empty{参数}为空
11304The country partner located is not open国家不支持
11340{parameter} error{参数}错误

响应示例

  • 入参示例:

    {
      "image": "/9j/4AAQSkZJRgABAQAAeAB4AAD/********XLiqqauzsw1J3sf/2Q==",
      "country": "PK"
    }
    
  • 业务请求成功

{
   "result":"success",
   "code":200,
   "sequence_id":"1704275269816000X0A366B271******",
   "message":"success",
   "card_info":{
     "birthday":"10/12/19**",
     "identifier":"ش**تل",
     "id_number":"3****-21*****-1",
     "card_side":"front",
     "country_of_stay":"",
     "gender":"M",
     "issue_date":"",
     "father_name":"",
     "expiry_date":"",
     "name":"",
     "father_name_urdu":"و*****شق",
     "name_urdu":"نم*****د"
   }
}
  • 业务不请求成功
  • {
        "code": 11350,
        "sequence_id": "69b57131b6fb********61ccba118b60",
        "message": "Internal error"
    }