tencent cloud

APIs

MainlandPermitOCR

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-07-02 16:22:04

1. API Description

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

This API is used to recognize all fields on the front of a mainland travel permit for Hong Kong, Macao, or Taiwan residents: name in Chinese, name in English, gender, date of birth, issuing authority, validity period, document number, place of issuance, number of issues, and document type.

A maximum of 20 requests can be initiated per second for this API.

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: MainlandPermitOCR.
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 The Base64-encoded value of the image.
Supported image formats: PNG, JPG, and JPEG. GIF is currently not supported.
Supported image size: The downloaded image after Base64 encoding can be up to 7 MB. The download time of the image cannot exceed 3s.
Either ImageUrl or ImageBase64 of the image must be provided. If both are provided, only ImageUrl is used.
ImageUrl No String The URL of the image.
Supported image formats: PNG, JPG, and JPEG. GIF is currently not supported.
Supported image size: The downloaded image after Base64 encoding can be up to 7 MB. The download time of the image cannot exceed 3s.
We recommend that you store the image in Tencent Cloud for higher download speed and stability.
The download speed and stability of non-Tencent Cloud URLs may be low.
RetProfile No Boolean Whether to return the ID photo. By default, the ID photo is not returned.
CardSide No String The side of the document. Valid values: FRONT (front side, default),
BACK (back side, only supported for Mainland Travel Permit for inbound visits).
Note: Back side recognition is only supported for the "Mainland Travel Permit for Hong Kong and Macao Residents" , and is not supported for Hong Kong, Macao, or Taiwan passes.

3. Output Parameters

Parameter Name Type Description
Name String Name in Chinese
EnglishName String Name in English
Sex String Gender
Birthday String Date of birth
IssueAuthority String Issuing authority
ValidDate String Validity period
Number String ID number
IssueAddress String Place of issue
IssueNumber String Number of issues
Type String Document type, such as: Mainland Travel Permit for Taiwan Residents, Mainland Travel Permit for Hong Kong and Macao Residents, or Exit-Entry Permit for Travelling to and from Hong Kong and Macao.
Profile String Base64-encoded profile photo, which is returned only when RetProfile is set to True
Nationality String Nationality of the document holder.
MainlandTravelPermitBackInfos MainlandTravelPermitBackInfos Information on the back of the document.
Note: Only supported for the back side of the Mainland Travel Permit for Hong Kong and Macao Residents.
WarnCardInfos Array of Integer Warning information for the document. This field is only valid for international site requests.
Warning codes:
-9102: photocopy warning;
-9103: recapture warning;
-9104: Photoshopped document warning;
-9109: warning capability not enabled.
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 MainlandPermitOCR

MainlandPermitOCR

Input Example

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

{
    "ImageUrl": "https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/card/MainlandPermitOCR/MainlandPermitOCR1.png",
    "RetProfile": false
}

Output Example

{
    "Response": {
        "EnglishName": "LI,YOU-TU",
        "MainlandTravelPermitBackInfos": {
            "HistoryNumber": "",
            "IDNumber": ""
        },
        "Nationality": "",
        "RequestId": "bd8fb0bc-6558-48b5-b057-2b04edacf225"
    }
}

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.ImageDecodeFailed Failed to decode the image.
FailedOperation.ImageNoSpecifiedCard The card in the image is not of the specified type.
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.
InvalidParameterValue.InvalidParameterValueLimit Incorrect parameter value.
LimitExceeded.TooLargeFileError The file size exceeds the limit
ResourceUnavailable.InArrears The account has insufficient balance.
ResourcesSoldOut.ChargeStatusException The billing status is abnormal.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan