tencent cloud

APIs

PermitOCR

Download
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-07-02 16:21:54

1. API Description

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

This API is used to recognize the fields on an exit/entry permit (card) for traveling to and from Hong Kong, Macao, or Taiwan, including place of issuance, issuing authority, validity period, gender, date of birth, name in English, name in Chinese, and document number.

A maximum of 10 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: PermitOCR.
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 cannot exceed 7 MB. The download time of the image cannot exceed 3 seconds. 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 cannot exceed 7 MB. The download time of the image cannot exceed 3 seconds. We recommend that you store the image in Tencent Cloud for higher download speed and stability. The download speed and stability of images stored outside Tencent Cloud may be compromised.
CropPortrait No Boolean Whether to return the ID photo. The default value is false.

3. Output Parameters

Parameter Name Type Description
Name String Name in Chinese
EnglishName String English name
Number String ID number
Sex String Gender
ValidDate String Validity period
IssueAuthority String Issuing authority
IssueAddress String Place of issue
Birthday String Date of birth
PortraitImage String Base64-encoded profile photo of the document holder.
Type String Document type, such as: Exit-Entry Permit for Travelling to and from Hong Kong and Macao, or Exit-Entry Permit for Travelling to and from Taiwan.
WarnCardInfos Array of Integer Warning information for the document. This field is only valid for international site requests. Warning codes:
-9101: Incomplete card border warning
-9102: Photocopied card warning
-9103: Recaptured card warning
-9104: Photoshopped card warning
-9107: Reflective card warning
-9108: Blurry image 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 PermitOCR API call

Input Example

POST / HTTP/1.1
Host: ocr.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: PermitOCR
<Common request parameters>

{
    "ImageUrl": "https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/card/PermitOCR/PermitOCR1.jpg"
}

Output Example

{
    "Response": {
        "Birthday": "1900.10.27",
        "EnglishName": "XXX,XXXX",
        "IssueAddress": "XX",
"IssueAuthority": "Exit and Entry Administration of the Ministry of Public Security"
"Name": "Name",
        "Number": "C900001111",
        "PortraitImage": "",
        "RequestId": "fedf285d-60bc-4e46-8d27-3f1d80bb19f6",
"Sex": "Female",
"Type": "Mainland Travel Permit for Hong Kong and Macao Residents"
        "ValidDate": "2018.10.09-2028.10.08"
    }
}

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