HKIDCardOCR

Last updated: 2021-04-12 14:14:14

    1. API Description

    Domain name for API request: ocr.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. It can check for card authenticity and crop the identity photo.

    This API is not fully available for the time being. For more information, please contact your Tencent Cloud sales rep.

    A maximum of 5 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 parameter. The value used for this API: HKIDCardOCR.
    Version Yes String Common parameter. The value used for this API: 2018-11-19.
    Region Yes String Common parameter. For more information, please see the list of regions supported by the product. This API only supports: ap-beijing, ap-guangzhou, ap-hongkong, ap-seoul, ap-shanghai, na-toronto
    DetectFake Yes Boolean Whether to check for authenticity.
    ReturnHeadImage Yes Boolean Whether to return identity photo.
    ImageBase64 No String Base64-encoded value of image.
    Supported image formats: PNG, JPG, JPEG. GIF is currently not supported.
    Supported image size: the downloaded image cannot exceed 3 MB in size after being Base64-encoded. The download time of the image cannot exceed 3 seconds.
    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
    FakeDetectResult Integer Authenticity check.
    0: unable to judge (because the image is blurred, incomplete, reflective, too dark, etc.);
    1: forged;
    2: authentic.
    Note: this field may return null, indicating that no valid values can be obtained.
    HeadImage String Base64-encoded identity photo
    Note: this field may return null, indicating that no valid values can be obtained.
    WarningCode Array of Integer Multiple alarm codes. If the ID card is spoofed, photocopied, or doctored, the corresponding alarm code will be returned.
    -9102: alarm for photocopied document
    -9103: alarm for spoofed document
    -9104: alarm for doctored document
    -9105: alarm for forged document
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Recognizing a Hong Kong (China) identity card

    Input Example

    https://ocr.tencentcloudapi.com/?Action=HKIDCardOCR
    &ImageUrl=https://xx/a.jpg
    &DetectFake=true
    &ReturnHeadImage=false
    &<Common request parameters>
    

    Output Example

    {
      "Response": {
        "CnName": "SAN, Nan",
        "EnName": "SAN, Nan",
        "TelexCode": "300000000000",
        "Sex": "Female",
        "Birthday": "01-01-2001",
        "Permanent": 1,
        "IdNum": "C000000(E)",
        "Symbol": "***AZ",
        "FirstIssueDate": "(09-99)",
        "CurrentIssueDate": "23-09-10",
        "FakeDetectResult": 1,
        "WarningCode": [
          -9102,
          -9103
        ],
        "HeadImage": "xx",
        "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.
    FailedOperation.UnKnowError Unknown error.
    FailedOperation.UnOpenError The service is not activated.
    InvalidParameterValue.InvalidParameterValueLimit Incorrect parameter value.
    LimitExceeded.TooLargeFileError The file is too large.
    ResourcesSoldOut.ChargeStatusException Exceptional billing status.