API Reference
English

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其他额外返回值可选枚举值:
1. document_forgery:返回证件伪造检测相关的参数,该字段仅在印尼节点生效
2. en:巴基斯坦身份证英文翻译结果,该字段仅在巴基斯坦节点生效。
以下字段将返回Urdu语的英文翻译结果:
- NIC证件的name、father_name字段
- NIC/CNIC证件的current_address_en、permanent_address_en字段
*备注:如果需要,请联系商务/运营单独开通该增强型配置。

响应参数

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

证件信息(card_info)

  • 印尼KTP
    字段字段类型描述
    nikStringID card
    nameStringName
    birthdayStringDate of birth
    birthplaceStringPlace of birth
    genderStringGender
    blood_typeStringBlood group
    addressStringAddress
    rt_rwStringRT/RW
    villageStringVillage
    streetStringStreet (District)
    religionStringReligion
    marital_statusStringMarital status
    occupationStringCareer
    nationalityStringCountry of Citizenship
    expiry_dateStringValidity period
    issue_dateStringIssue date
    issue_locationStringIssue location
    provinceStringProvince of residence
    cityStringCity
  • 巴基斯坦身份证(正面/反面)
    字段类型描述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

证件伪造检测(document_forgery_info)

字段类型含义备注
resultString证件伪造检测总体结果枚举值:
1. pass:验证通过,证件未伪造
2. fail:验证失败,证件为伪造证件
detailObject证件伪造检测结果列表如果结果为通过,则不返回该字段;如果结果为失败,显示具体原因,包括黑白打印(black_white_print)、屏幕翻拍(screen_capture)

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": "ID",
  "options": "document_forgery"
}
  • 印尼业务请求成功:
{
    "result": "success",
    "code": 200,
    "sequence_id": "1721890950247464I31676CAC******",
    "message": "success",
    "card_info": {
        "birthday": "26-05-19**",
        "address": "KP.C****",
        "occupation": "WIRA****",
        "gender": "LAKI-LAKI",
        "city": "KABU****",
        "expiry_date": "SE****",
        "issue_location": "B****",
        "religion": "IS****",
        "nik": "327****60577****",
        "marital_status": "KAWIN",
        "birthplace": "BA****",
        "nationality": "WN****",
        "issue_date": "28-02-20**",
        "province": "JAWA****",
        "street": "MEGAMEND****",
        "blood_type": "-",
        "name": "M.TAUFAN****",
        "village": "CIPAY****",
        "rt_rw": "005/****"
    },
  "document_forgery_info":{
     "result":"fail",
     "detail":[
       "black_white_print"
     ]
  }
}
  • 巴基斯坦业务请求成功:
{
   "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"
}