tencent cloud



Last updated: 2022-09-07 15:08:39

1. API Description

Domain name for API request: ocr.tencentcloudapi.com.

This API is used to recognize a passport issued in Hong Kong/Macao/Taiwan (China) or other countries/regions. Recognizable fields include passport ID, name, date of birth, gender, expiration date, issuing country/region, and nationality. It has the features of cropping identity photos and alarming for photographed or photocopied documents.

This API is not fully available for the time being. For more information, please contact your Tencent Cloud sales rep.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: MLIDPassportOCR.
Version Yes String Common Params. The value used for this API: 2018-11-19.
Region Yes String Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-guangzhou, ap-singapore.
ImageBase64 Yes String Base64-encoded value of image. The image cannot exceed 7 MB in size after being Base64-encoded. A resolution above 500x800 is recommended. PNG, JPG, JPEG, and BMP formats are supported. It is recommended that the card part occupies more than 2/3 area of the image.
RetImage No Boolean Whether to return an image. Default value: false.

3. Output Parameters

Parameter Name Type Description
ID String Passport ID
Name String Name
DateOfBirth String Date of birth
Sex String Gender (F: female, M: male)
DateOfExpiration String Expiration date
IssuingCountry String Issuing country
Nationality String Country/region code
Warn Array of Integer Alarm code
-9103 Alarm for spoofed card
-9102 Alarm for photocopied card
-9106 Alarm for covered card
Image String Identity photo
AdvancedInfo String Extended field:
CodeSet String The first row of the machine-readable zone (MRZ) at the bottom
CodeCrc String The second row of the MRZ at the bottom
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example


Example1 Recognizing a non-Chinese mainland passport (debugging tool)

Input Example

Host: ocr.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: MLIDPassportOCR
<Common request parameters>

    "ImageBase64": "base64 encoding"

Output Example

    "Response": {
        "ID": "E6918C",
        "Name": "LIM HEG CHUN STEE",
        "IssuingCountry": "SGP",
        "Nationality": "SGP",
        "DateOfBirth": "",
        "Sex": "M",
        "DateOfExpiration": "230414",
        "Warn": [],
        "Image": "",
        "AdvancedInfo": "{\"IssuingCountry\":{\"Confidence\":\"0.9500\"},\"Name\":{\"Confidence\":\"0.9500\"},\"ID\":{\"Confidence\":\"0.9500\"},\"Nationality\":{\"Confidence\":\"0.9500\"},\"Sex\":{\"Confidence\":\"0.9500\"},\"DateOfExpiration\":{\"Confidence\":\"0.9500\"}}",
        "CodeSet": "P<CANBROWN<<BENJAMIN<<<<<<<<<<<<<<<<<<<<<<<<",
        "CodeCrc": "JK123488<3CAN8510168M2603298<<<<<<<<<<<<<<04",
        "RequestId": "0ee989d3-d064-45ec-bccb-63f5064247b4"

5. Developer Resources


TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.DownLoadError File download failed.
FailedOperation.ImageDecodeFailed Image decoding failed.
FailedOperation.NoPassport Not a passport.
FailedOperation.OcrFailed OCR failed.
FailedOperation.UnKnowError Unknown error.
FailedOperation.UnOpenError The service is not activated.
InvalidParameterValue.InvalidParameterValueLimit Incorrect parameter value.
LimitExceeded.TooLargeFileError The file is too large.
ResourcesSoldOut.ChargeStatusException Exceptional billing status.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support