BankCardOCR

Last updated: 2021-10-13 16:17:00

    1. API Description

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

    This API is used to detect and recognize key fields such as the card number, bank information, and expiration date on mainstream bank cards in Mainland China.

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

    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 parameter. The value used for this API: BankCardOCR.
    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
    ImageBase64 No String Base64-encoded value of the image. The image cannot exceed 7 MB after being Base64-encoded. A resolution above 500 x 800 is recommended. PNG, JPG, JPEG, and BMP formats are supported. It is recommended that the card part occupy more than 2/3 area of the image.
    Either the ImageUrl or ImageBase64 of the image must be provided. If both are provided, only ImageUrl will be used.
    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 7 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.
    RetBorderCutImage No Boolean Whether to return the bank card image data after preprocessing (precise cropping and alignment). Default value: false
    RetCardNoImage No Boolean Whether to return the card number image data after slicing. Default value: false
    EnableCopyCheck No Boolean Whether to enable photocopy check. If the input image is a bank card photocopy, an alarm will be returned. Default value: false
    EnableReshootCheck No Boolean Whether to enable photograph check. If the input image is a bank card photograph, an alarm will be returned. Default value: false
    EnableBorderCheck No Boolean Whether to enable obscured border check. If the input image is a bank card with obscured border, an alarm will be returned. Default value: false
    EnableQualityValue No Boolean Whether to return the image quality value, which measures how clear an image is. Default value: false

    3. Output Parameters

    Parameter Name Type Description
    CardNo String Card number
    BankInfo String Bank information
    ValidDate String Expiration date. Format: 07/2023
    CardType String Card type
    CardName String Card name
    BorderCutImage String Sliced image data
    Note: this field may return null, indicating that no valid values can be obtained.
    CardNoImage String Card number image data
    Note: this field may return null, indicating that no valid values can be obtained.
    WarningCode Array of Integer Warning code:
    -9110: the bank card date is invalid.
    -9111: the bank card border is incomplete.
    -9112: the bank card image is reflective.
    -9113: the bank card image is a photocopy.
    -9114: the bank card image is a photograph.
    Multiple warning codes may be returned at a time.
    Note: this field may return null, indicating that no valid values can be obtained.
    QualityValue Integer Image quality value, which is returned when EnableQualityValue is set to true. The smaller the value, the less clear the image is. Value range: 0−100 (a threshold greater than or equal to 50 is recommended.)
    Note: This field may return null, indicating that no valid values can be obtained.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Recognizing a bank card

    Input Example

    https://ocr.tencentcloudapi.com/?Action=BankCardOCR
    &ImageUrl=https://xx/a.jpg
    &<Common request parameters>
    

    Output Example

    {
    "Response": {
      "BankInfo": "China Merchants Bank (03080000)",
      "ValidDate": "07/2023",
      "CardType": "Credit card",
      "CardName": "China Merchants Bank credit card",
      "BorderCutImage": null,
      "CardNoImage": null,
      "QualityValue": 80,
      "WarningCode": [
        -9110
      ],
      "CardNo": "6225768888888888",
      "RequestId": "68f8fcbf-6004-0111a-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 File download failed.
    FailedOperation.ImageDecodeFailed Image decoding failed.
    FailedOperation.OcrFailed OCR failed.
    FailedOperation.UnKnowError Unknown error.
    FailedOperation.UnOpenError The service is not activated.
    InvalidParameter.EngineImageDecodeFailed Image decoding failed.
    InvalidParameterValue.InvalidParameterValueLimit Incorrect parameter value.
    LimitExceeded.TooLargeFileError The file is too large.
    ResourcesSoldOut.ChargeStatusException Exceptional billing status.