tencent cloud

APIs

RecognizeMacaoIDCardOCR

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-07-02 16:21:48

1. API Description

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

This API is used to recognize key fields on the photo side of a Macao (China) identity card, including name in Chinese, name in English, telecode for name, date of birth, gender, document symbol, date of the first issue, date of the last receipt, identity card number, and permanent residency attribute.

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: RecognizeMacaoIDCardOCR.
Version Yes String Common Params. The value used for this API: 2018-11-19.
Region No String Common Params. This parameter is not required.
ImageUrl No String The URL address of the image.
Supported image formats: PNG, JPG, JPEG. Not support GIF yet.
Supported image size: The downloaded image should not exceed 7M. The image download takes no more than 3 seconds.Storing images in Tencent Cloud URLs can ensure higher download speed and stability. It is recommended that images be stored in Tencent Cloud. The URL speed and stability of non-Tencent cloud storage may be affected to a certain extent.
BackImageUrl No String The URL address of the image on the back of the card. Supported image formats: PNG, JPG, JPEG. The GIF format is not supported yet. Supported image size: The downloaded image does not exceed 7M after Base64 encoding. The image download takes no more than 3 seconds. Storing images in Tencent Cloud URLs can ensure higher download speed and stability. It is recommended that images be stored in Tencent Cloud. The URL speed and stability of non-Tencent cloud storage may be affected to a certain extent.
ImageBase64 No String Base64 value of the image.Supported image formats: PNG, JPG, JPEG. Not support GIF yet.
Supported image size: The downloaded image should not exceed 7M after Base64 encoding. The image download takes no more than 3 seconds.
One of ImageUrl and ImageBase64 of the image must be provided. If both are provided, only ImageUrl will be used.
BackImageBase64 No String Base64 value of the image on the back of the card. Supported image formats: PNG, JPG, JPEG. The GIF format is not supported yet. Supported image size: The downloaded image does not exceed 7M after Base64 encoding. The image download takes no more than 3 seconds. One of ImageUrl and ImageBase64 of the image must be provided. If both are provided, only ImageUrl will be used.
Config No String The following optional fields are of string type and are empty by default:
RetImage: whether to return the processed image (base64 encrypted string); the value and meaning of RetImage are as follows: 1.portrait Return portrait image data 2."" Do not return image data SDK setting method reference: Config = Json.stringify({"RetImage":"portrait"}) API 3.0 Explorer setting method reference: Config = {"RetImage":"portrait" }

3. Output Parameters

Parameter Name Type Description
CnLastName String Last name in Chinese
EnLastName String Last name in English
LastNameCode String Telecode of the last name in Chinese
CnFirstName String First name in Chinese
EnFirstName String First name in English
FirstNameCode String Telecode of the first name in Chinese
ID String Identity card number
Birthday String Date of birth (DD-MM-YYYY)
Sex String Gender
FirstIssueDate String Date of first issue (DD-MM-YYYY)
CurrentIssueDate String Date of issue (DD-MM-YYYY)
ValidityPeriod String Validity period (DD-MM-YYYY)
Symbol String Document symbol
Height String Height (unit: meters)
RetImage String Processed image (Base64)
ResidentType String Resident type.
Valid values: Permanent Resident Identity Card, Non-permanent Resident Identity Card.
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 image,
-9109 This capability is 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 Recognizes Macao (China) identity card

Recognizes Macao (China) identity card

Input Example


https://ocr.intl.tencentcloudapi.com/?Action=RecognizeMacaoIDCardOCR
&ImageUrl=https://xx/a.jpg
&Config={\"RetImage\":\"preprocess\"}
&<public parameters>

Output Example

{
    "Response": {
        "Angle": "0",
        "CnLastName": "",
        "EnLastName": "HO",
        "LastNameCode": "0149",
        "CnFirstName": "*",
        "EnFirstName": "CHAN YOU",
        "FirstNameCode": "37****27",
        "ID": "15****0(4)",
        "Birthday": "22-04-1997",
        "Sex": "F",
        "FirstIssueDate": "06-05-2011",
        "CurrentIssueDate": "01-08-2014",
        "ValidityPeriod": "01-08-2024",
        "Symbol": "C",
        "Height": "1.64",
        "RetImage": "",
        "RequestId": "68f8fcbf-9314-6112a-ac18-6f1a9308fs100mab"
    }
}

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.EmptyImageError The image is empty.
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.
FailedOperation.WarningServiceFailed The general warning service encountered an exception.
InvalidParameter.ConfigFormatError Config is not in valid JSON format.
InvalidParameterValue.InvalidParameterValueLimit Incorrect parameter value.
LimitExceeded.TooLargeFileError The file size exceeds the limit

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan