API Reference
中文

OCR API

OCR API provides document image recognition and returns corresponding document information.

API Method

Base URL

API

URLRequest MethodsContent-TypeOutput FormatCharacter Set
api-base-url?partner_code=xxx&partner_key=xxxPOSTapplication/jsonJSONUTF-8

Authentication

ParameterTypeDescriptionRequired/OptionalNotes
partner_codeStringPartner CodeRequiredAssigned by TD
partner_keyStringPartner KeyRequiredAssigned by TD

Request Parameter

ParameterTypeDescriptionRequired/OptionalNotes
imageStringID card imageRequiredID photo,base64 photo of JPG,JPEG,PNG format, the image size limits to 3M
countryStringCountryRequired2-letter country code according to ISO 3166.
Only support: Indonesia(ID), Pakistan(PK)
optionsStringAdditional feature outputOptionalEnumeration:
1. document_forgery: Returns forgery detection parameters (Indonesia only)
2. en: English translation for Pakistani ID fields (Pakistan only).
The following fields will return the English translation results of Urdu language:
-'name' and 'fathername' fields of NIC documents
-'currentaddress_en' and 'permanent_address_en' fields of NIC/CNIC documents
*Note: If required, please contact business/operations for individual activation of this enhanced configuration.

Response Parameter

ParameterTypeDescriptionRequired/OptionalNote
codeIntegerAPI status codeRequired
messageStringStatus InformationRequiredSpecific error reasons will be provided when the API is abnormal
sequence_idStringUnique response codeRequiredA unique ID used to track each request
resultStringResultConditionally RequiredReturned when code=200.
Enumeration:
1. success
2. fail
card_infoJSONObjectID card informationConditionally RequiredReturned when result is success
document_forgery_infoJSONObjectDocument forgery detectionConditional: Returns when result is successReturned if specified in options

ID Information (card_info)

  • KTP
    ParameterTypeDescription
    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
  • Pakistan NIC/CNIC(front and back side)
    ParameterTypeDescriptionCNIC 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
    Note: If English translation is required for this field of the NIC document, please contact business/operations to individually activate this enhanced configuration.
    CNIC
    name_urduStringName in UrduCNIC/NIC
    birthdayStringDate of birthCNIC/NIC
    genderStringGenderCNIC/NIC
    father_nameStringFather's name
    Note: If English translation is required for this field of the NIC document, please contact business/operations to individually activate this enhanced configuration.
    CNIC/NIC
    father_name_urduStringFather's name in UrduCNIC/NIC
    identifierStringPersonal identifierNIC
    country_of_stayStringCountry of stayCNIC
    ParameterTypeDescriptionCNIC 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_enStringCurrent address in English
    Note: If required, please contact business/operations to individually activate this enhanced configuration.
    CNIC/NIC
    permanent_address_enStringPermanent address in English
    Note: If required, please contact business/operations to individually activate this enhanced configuration.
    CNIC/NIC

Document Forgery Detection (document_forgery_info)

ParameterTypeDescriptionNotes
resultStringOverall result of forgery detectionEnumeration:
1. pass: Passed, document is not forged
2. fail: Failed, document is forged
detailObjectList of forgery detection detailsIf the result is "pass", this field is not returned; if the result is "fail", this field will list specific reasons, such as "black_white_print" (black and white print) and "screen_capture" (screen capture)

API Status Code

Code MessageDescription
200SuccessCall Successfully
301Service not purchasedNo purchase of the servive
302Traffic blockedTraffic blocked
303Traffic insufficientTraffic insufficient
304Service expiredService expired
305Daily maximum volume reachedDaily maximum volume reached
12601Detection failedCannot recognize this image
12602Document detected as having bad qualityThe document has been detected but the quality is low.
*Only applies to Indonesian OCR service
11350Internal errorInternal error
11301{parameter} empty{parameter} empty
11304The country partner located is not openThe country partner located is not open
11340{parameter} error{parameter} error

Response Example

  • Request:
{
  "image": "/9j/4AAQSkZJRgABAQAAeAB4AAD/********XLiqqauzsw1J3sf/2Q==",
  "country": "ID",
  "options": "document_forgery"
}
  • Success (Indonesian):
{
    "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"
     ]
  }
}
  • Success (Pakistani):
{
   "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":"نم*****د"
   }
}
  • Failed:
{
    "code": 11350,
    "sequence_id": "69b57131b6fb********61ccba118b60",
    "message": "Internal error"
}