tencent cloud

HKIDCardOCR
最后更新时间:2025-11-19 14:32:34
HKIDCardOCR
最后更新时间: 2025-11-19 14:32:34

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 Hong Kong (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: HKIDCardOCR.
Version Yes String Common Params. The value used for this API: 2018-11-19.
Region No String Common Params. This parameter is not required.
ReturnHeadImage No Boolean Whether to return identity photo.
ImageBase64 No String Base64 string of the image
Supported image formats: PNG, JPG, JPEG. GIF is not supported yet.
Supported image size: The downloaded image cannot exceed 7 MB after being Base64-encoded, and it cannot take longer than 3 seconds to download the image.
ImageUrl No String URL address of image. (This field is not supported outside Chinese mainland)
Supported image formats: PNG, JPG, JPEG. GIF is currently not supported.
Supported image size: the downloaded image cannot exceed 3 MB after being Base64-encoded. The download time of the image cannot exceed 3 seconds.
We recommend you store the image in Tencent Cloud, as a Tencent Cloud URL can guarantee higher download speed and stability.
The download speed and stability of non-Tencent Cloud URLs may be low.

3. Output Parameters

Parameter Name Type Description
CnName String Name in Chinese
EnName String Name in English
TelexCode String Telecode for the name in Chinese
Sex String Gender. Valid values: Male, Female
Birthday String Date of birth
Permanent Integer Permanent identity card.
0: non-permanent;
1: permanent;
-1: unknown.
IdNum String Identity card number
Symbol String Document symbol, i.e., the symbol under the date of birth, such as "***AZ"
FirstIssueDate String First issue date
CurrentIssueDate String Last receipt date
HeadImage String Base64-encoded large primary portrait photo from the left side of the new-generation Hong Kong Identity Card.
Note: this field may return null, indicating that no valid values can be obtained.
SmallHeadImage String Base64-encoded small secondary portrait photo from the right side of the new-generation Hong Kong Identity Card.
Note: this field may return null, indicating that no valid values can be obtained.
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.
WindowEmbeddedText String Text information incorporated within the laser-perforated see-through window on the new-generation Hong Kong Identity Card.
HKIDVersion String Versions of the Hong Kong Identity Card: HKID-2018, HKID-2003.
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 Recognizing Hong Kong (China) identity card

Input Example

POST / HTTP/1.1
Host: ocr.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: HKIDCardOCR

{
    "ReturnHeadImage": "false",
    "ImageUrl": "https://xx/a.jpg"
}

Output Example

{
    "Response": {
        "CnName": "",
        "EnName": "SAN, Nan",
        "TelexCode": "300000000000",
        "Sex": "",
        "Birthday": "01-01-2001",
        "Permanent": 1,
        "IdNum": "C000000(E)",
        "Symbol": "***AZ",
        "FirstIssueDate": "(09-99)",
        "CurrentIssueDate": "23-09-10",
        "HeadImage": "",
        "WarnCardInfos": [
            -9104
        ],
        "RequestId": "fba1c9ad-aeb3-4418-9ecf-80ab1b5fc875"
    }
}

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 File download failed.
FailedOperation.ImageDecodeFailed Image decoding failed.
FailedOperation.NoHKIDCard Not a Hong Kong identity card.
FailedOperation.OcrFailed OCR failed. This error may be caused by unstable network connections,service anomalies or other issues.
FailedOperation.UnKnowError Unknown error.
FailedOperation.UnOpenError The service is not activated.
FailedOperation.WarningServiceFailed Warning service error.
InvalidParameterValue.InvalidParameterValueLimit Incorrect parameter value.
LimitExceeded.TooLargeFileError The file is too large.
ResourceUnavailable.InArrears The account is in arrears.
ResourcesSoldOut.ChargeStatusException Exceptional billing status.
本页内容是否解决了您的问题?
您也可以 联系销售 提交工单 以寻求帮助。

文档反馈