This topic describes how to use DocOcr API.
Interface description
Interface name: DocOcr.
Service address:cloudauth-intl.cn-hongkong.aliyuncs.com.
Request method: HTTPS POST.
Interface description: DocOcr API provides the capabilities of information extraction via OCR (Optical Character Recognition) technology for most of the identity documents like passport, ID card, etc. along with anti-spoofing check.
Request parameters
Parameter | Type | Required | Description | Example |
ProductCode | String | Yes | Set to ID_OCR_MIN in this mode. | ID_OCR_MIN |
MerchantBizId | String | Yes | A unique business ID for tracing purpose. For example, the sequence ID from the merchant's business-related database. Note The Alibaba Cloud server does not perform uniqueness check on the value of this field. For better tracking, it is strongly recommended to enable the merchant server to guarantee the uniqueness of the business ID. | e0c34a77f5ac40a5aa5e6ed20c35**** |
MerchantUserId | String | Yes | Merchant user ID, or other identifiers that can be used to identify a specific user, for example, mobile phone number, email address and so on. It is strongly recommended to pre-desensitize the value of the userId field, for example, by hashing the value. | 123456789 |
IdOcrPictureBase64 | String | No | Front image of ID card, binary stream base64 encoding. Note IdOcrPictureBase64 or IdOcrPictureUrl need to be set. If you choose IdOcrPictureBase64 to transfer ID image, please pay attention to check the size of the image, and do not import too large image. | base64 |
IdOcrPictureUrl | String | No | The HTTPS or HTTP address of the image of the front side of ID card. Note IdOcrPictureBase64 or IdOcrPictureUrl need to be set. | https://*** |
DocType | String | Yes | Document type, consisting of 8 digits, with mapping detailed in the table below. | 00000006 |
Ocr | String | Yes | Whether to enable the information extraction of the identity documents. The following values are supported:
By default, the value of T is used. | T |
IdFaceQuality | String | No | Whether to return the quality check result of the input profile image. The following values are supported:
By default, the value of F is used. | F |
Spoof | String | No | Whether to enable anti-spoofing detection of the identity documents. The following values are supported:
By default, the value of F is used. | F |
DocType List
DocType | CertType |
01000000 | Passport for all countries |
00000006 | HKID 2003 version (Hong Kong Identity Card) |
00000008 | HKID 2018 version (Hong Kong Identity Card) |
00000007 | China Exit-Entry Permit for Travelling to and from Hong Kong and Macao |
00000009 | China Mainland Travel Permit for Hong Kong and Macao Residents |
000000011 | Macau Identity Card |
000000012 | China Mainland Travel Permit for Taiwan Residents |
Response parameters
Field name | Data type | Description | Example | |
HTTP Status Code | Integer | The HTTP status code. | 200 | |
HTTP Body | RequestId | String | The unique ID of the request, which can be used to locate issues. | 130A2C10-B9EE-4D84-88E3-5384FF039795 |
Code | String | Return code. For the full list of codes, see Codes and Messages. | Success | |
Message | String | Response detailed message. | success | |
Result.TransactionId | String | A unique transaction ID that is generated by the Alibaba Cloud server for the identity proofing process. Note When an error occurs during the process, for example, invalid argument, no transaction ID is returned. | hksf3e9312e119b15549d26b5b68e40e | |
Result.Passed | String | Certification result. Possible values and their meanings are as below:
| Y | |
Result.SubCode | String | Authentication result sub code. | 200 | |
Result.ExtIdInfo | String | Optional. JSON string of ExtIdInfo. Detailed information about identity document recognition. For more information, see ExtIdInfo. |
|
Codes and Messages
HTTP Status Code | Code | Message |
200 | Success | The request has succeeded. |
400 | MissingParameter | The parameter is missing. |
400 | InvalidParameter | The parameter is invalid. |
403 | Forbidden.RAMUserAccessDenied | Grant AliyunAntCloudAuthFullAccess permission to the RAM user. For more information, see Authorize a RAM user to access Real ID. |
403 | Forbidden.AccountAccessDenied | The account is unauthorized, overdue, deactivated, or disabled. |
403 | Throttling.Api | Request was denied due to api flow control. |
500 | InternalError | The error message returned because a temporary server error occurs. We recommend that you try again. If the error code persists, please submit a ticket for help. |
SubCode
SubCode | Whether billing | Message |
200 | Yes | Pass. |
211 | Yes | Low quality or incomplete document. Documents are low-quality or partially visible so that no definitive conclusions can be made. |
212 | Yes | The result of certificate anti-counterfeiting detection indicates tampering, screen recapture or photo copy are detected. |
213 | Yes | No ID detected. The required type of ID can not be detected. |
ExtIdInfo
Field name | Data type | Description | Example |
ocrIdInfo | String | Optional. Specified only when the value of the Ocr field in the request is set to T. Document OCR identification information. Json string. See the "OCR extraction field" column for details on the content format. Note If authentication or OCR fails, this parameter is left empty. |
|
idFaceQualityScore | Double | Optional. The quality score of the input profile image. Specified only when the value of the IdFaceQuality field in the request is set to T. The value of this field is between 0 and 100. | 99.95 |
spoofInfo | String | Optional. Specified only when the value of the Spoofing field in the request is set to T.Spoofing check results of Identity document and corresponding types. Valid values:
|
|
OCR extraction field
HKID (Hong Kong Identity Card)
Both of 2003 and 2018 smart card version are included.
Field name | Data type | Description |
name | String | Chinese Name. |
englishName | String | English Name. |
nameCode | String | Telex code, which is corresponding to the Chinese name. |
sex | String | Gender. Valid values:
|
birthDate | String | Date of birth. |
idNumber | String | ID number. |
currentIssueDate | String | Date of latest registration. |
firstIssueDate | String | Month and year of first registration. |
isPermanent | String | Whether it is a permanent residence identity card. Valid values:
|
symbols | String | Symbols below the date of Birth. Such as "***AZ". |
China Exit-Entry Permit for Travelling to and from Hong Kong and Macao
Field name | Data type | Description |
name | String | Chinese Name. |
englishName | String | English Name. |
sex | String | Gender. |
birthDate | String | Date of birth. |
idNumber | String | ID number. |
issueDate | String | Date of issuance. |
expiryDate | String | Date of expiry. |
placeOfIssue | String | Place of issue. |
originOfIssue | String | Authority for issue. |
China Mainland Travel Permit for Hong Kong and Macao Residents
Field name | Data type | Description |
name | String | Chinese Name. |
englishName | String | English Name. |
sex | String | Gender. |
birthDate | String | Date of birth. |
idNumber | String | ID number. |
issueDate | String | Date of Issuance. |
expiryDate | String | Date of Expiry. |
originOfIssue | String | Authority for issue. |
Passport for all countries
Field name | Data type | Description |
surname | String | Surname. |
givenname | String | Given name. |
sex | String | Gender. |
birthDate | String | Date of birth. |
passportNo | String | Passport number. |
nationality | String | Country. |
expiryDate | String | Date of Expiry. |
countryCode | String | Country Code. |
Macau Identity Card
Field name | Data type | Description |
surnameCN | String | Chinese surname. |
givennameCN | String | Chinese given name. |
surname | String | Surname. |
givenname | String | Given name. |
sex | String | Gender. |
birthDate | String | Date of birth. |
idNumber | String | ID number. |
expiryDate | String | Date of Expiry. |
placeOfBirth | String | Code for place of birth. Such as "AS". |
China Mainland Travel Permit for Taiwan Residents
Field name | Data type | Description |
name | String | Chinese Name. |
englishName | String | English Name. |
sex | String | Gender. |
birthDate | String | Date of birth. |
idNumber | String | ID number. |
issueDate | String | Date of issuance. |
expiryDate | String | Date of expiry. |
originOfIssue | String | Authority for issue. |
placeOfIssue | String | Place of issue. |