tencent cloud

APIs

MLIDPassportOCR

Download
Modo Foco
Tamanho da Fonte
Última atualização: 2026-08-28 17:36:59

1. API Description

Domain name for API request: ocr.intl.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 interface supports regional scope: countries with machine-readable passports

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 No String Common Params. This parameter is not required.
ImageBase64 No String Base64-encoded image data. The image must be no larger than 7 MB after Base64 encoding. A resolution of at least 500x800 is recommended. Supported image formats: PNG, JPG, JPEG, BMP, and PDF. The document should occupy more than 2/3 of the image area.
RetImage No Boolean Whether to return an image.
Default value: false.
ImageUrl No String URL of the image. The downloaded image must be no larger than 7 MB after Base64 encoding. A resolution of at least 500x800 is recommended. Supported image formats: PNG, JPG, JPEG, BMP, and PDF. The document should occupy more than 2/3 of the image area. Image download must complete within 3 seconds. We recommend storing images in Tencent Cloud for higher download speed and stability. The speed and stability of URLs from non-Tencent Cloud storage may be affected. Note: This field is not supported outside the Chinese mainland region.

3. Output Parameters

Parameter Name Type Description
ID String Parsed passport ID extracted from the MRZ (Machine-Readable Zone) of passport
Name String Parsed full name extracted from the MRZ (Machine-Readable Zone) of passport
DateOfBirth String Parsed date of birth extracted from the MRZ (Machine-Readable Zone) of passport
Sex String Parsed gender extracted from the MRZ (Machine-Readable Zone) of passport
DateOfExpiration String Parsed expiry date extracted from the MRZ (Machine-Readable Zone) of passport
IssuingCountry String Parsed issuing country extracted from the MRZ (Machine-Readable Zone) of passport
Nationality String Parsed country-region code extracted from the MRZ (Machine-Readable Zone) of passport
Image String Base64-encoded identity photo
CodeSet String Parsed MRZ line 1 raw sequence extracted from the MRZ (Machine-Readable Zone) of passport
CodeCrc String Parsed MRZ line 2 raw sequence extracted from the MRZ (Machine-Readable Zone) of passport
Surname String Parsed surname extracted from the MRZ (Machine-Readable Zone) of passport
GivenName String Parsed given name extracted from the MRZ (Machine-Readable Zone) of passport
Type String Parsed document type extracted from the MRZ (Machine-Readable Zone) of passport
PassportRecognizeInfos PassportRecognizeInfos Document content in the visual zone
WarnCardInfos Array of Integer Card Warning Information

-9101 Alarm for covered certificate
-9102 Alarm for photocopied certificate
-9103 Alarm for photographed certificate
-9104 Alarm for PS certificate
-9107 Alarm for reflective certificate
-9108 Alarm for blurry certificate
-9109 This capability is not enabled. Please contact customer support to activate the alert service.
CardCount Integer The number of cards detected in the input image.(Currently supported only in ap-bangkok region)
IsComplete Boolean Whether the passport information is complete.
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Passport Recognition (Multiple Countries and Regions) Example Code

Passport recognition (multiple countries and regions)

Input Example

POST / HTTP/1.1
Host: ocr.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: MLIDPassportOCR
<Common Request Parameters>

{
    "ImageBase64": "https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/card/MLIDPassportOCR/MLIDPassportOCR1.png"
}

Output Example

{
    "Response": {
        "AdvancedInfo": "",
        "CodeCrc": "4567123452USA9004117F2107268713843748<708026",
        "CodeSet": "P<USACARTER<<ESTHER<<<<<<<<<<<<<<<<<<<<<<<<<",
        "DateOfBirth": "19900411",
        "DateOfExpiration": "20210726",
        "GivenName": "ESTHER",
        "ID": "456712345",
        "Image": "",
        "IssuingCountry": "USA",
        "Name": "CARTER ESTHER",
        "Nationality": "USA",
        "PassportRecognizeInfos": {
            "DateOfBirth": "11 Apr 1990",
            "DateOfExpiration": "26 Jul 2021",
            "DateOfIssuance": "27 Jul 2011",
            "GivenName": "ESTHER",
            "IssuePlace": "",
            "IssuingAuthority": "",
            "IssuingCountry": "USA",
            "Name": "",
            "Nationality": "UNITED STATES OF AMERICA",
            "PassportID": "456712345",
            "Sex": "F",
            "Signature": "",
            "Surname": "CARTER",
            "Type": "P"
        },
        "RequestId": "dad946b2-1288-4df9-a0b4-6abfaba1e170",
        "Sex": "F",
        "Surname": "CARTER",
        "Type": "P"
        "WarnCardInfos": [
            -9109
        ]
    }
}

5. Developer Resources

SDK

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 Failed to download the file.
FailedOperation.FieldException The field value does not meet expectations.
FailedOperation.ImageDecodeFailed Failed to decode the image.
FailedOperation.InconsistencyBetweenMRZAndVRZ The information in the visual zone does not match that in the machine-readable zone.
FailedOperation.NoPassport Not a passport.
FailedOperation.OcrFailed OCR recognition failed. This error may be caused by unstable network connections, service anomalies, or other issues.
FailedOperation.UnKnowError Unknown error.
FailedOperation.UnOpenError The service has not been activated.
FailedOperation.WarningServiceFailed The general warning service encountered an exception.
InvalidParameterValue.InvalidParameterValueLimit Incorrect parameter value.
LimitExceeded.TooLargeFileError The file size exceeds the limit
ResourceUnavailable.InArrears The account has insufficient balance.
ResourceUnavailable.ResourcePackageRunOut The resource package has been exhausted.
ResourcesSoldOut.ChargeStatusException The billing status is abnormal.

Ajuda e Suporte

Esta página foi útil?

comentários