Domain name for API request: ocr.intl.tencentcloudapi.com.
This interface recognizes all fields on both sides of the Mainland China Resident Identity Card (second-generation), including name, gender, ethnicity, date of birth, address, ID number, issuing authority, and validity period, with an accuracy of over 99%.
In addition, the interface provides additional features for various scenarios, such as ID card and portrait photo cropping, along with five alarm detections (see table below).
| Value-added ability | Ability items |
|---|---|
| Alarm function | |
| ID card photocopy warning | |
| ID card on-screen display warning | |
| Alarm for occlusion in the ID card frame | |
| ID card reflective warning | |
| Blurry picture warning |
A maximum of 20 requests can be initiated per second for this API.
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: RecognizeMainlandIDCardOCR. |
| Version | Yes | String | Common Params. The value used for this API: 2018-11-19. |
| Region | Yes | String | Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-singapore. |
| ImageBase64 | No | String | The Base64 value of the image. The image is required to be no larger than 7M after Base64 encoding, and the resolution is recommended to be 500*800 or above. PNG, JPG, JPEG, and BMP formats are supported. It is recommended that the card part occupies at least 2/3 of the picture. One of ImageUrl and ImageBase64 of the image must be provided. If both are provided, only ImageUrl will be used. |
| ImageUrl | No | String | The URL address of the image. The image is required to be no larger than 7M after Base64 encoding, and the resolution is recommended to be 500*800 or above. PNG, JPG, JPEG, and BMP formats are supported. It is recommended that the card part occupies at least 2/3 of the picture. It is recommended that images be stored in Tencent Cloud to ensure higher download speed and stability. |
| CardSide | No | String | FRONT: The side of the ID card with the photo (portrait side), BACK: The side of the ID card with the national emblem (national emblem side). If this parameter is not filled in, the front and back of the ID card will be automatically determined for you. |
| CropPortrait | No | Boolean | Whether to return the ID card portrait, the default is false |
| CropIdCard | No | Boolean | Whether to enable ID card photo cropping (removing excess edges outside the ID, automatically correcting the shooting angle), the default value is false |
| Parameter Name | Type | Description |
|---|---|---|
| Name | String | Name((portrait side)) |
| Sex | String | Gender (portrait side) |
| Nation | String | Ethnicity (portrait side) |
| Birth | String | Date of birth (portrait side) |
| Address | String | Address(portrait side) |
| IdNum | String | ID number (portrait side) |
| Authority | String | Issuing authority (national emblem side) |
| ValidDate | String | Validity period (national emblem side) |
| WarnCardInfos | Array of Integer | Warning information for the ID card. Valid warning codes: -9101 (incomplete card border), -9102 (photocopied document), -9103 (re-photographed document), -9104 (PS-altered document), -9107 (reflective document), -9108 (blurry image), -9109 (warning capability not enabled). |
| PortraitImage | String | Portrait image base64 |
| IdCardImage | String | ID card photo cropping results base64 |
| 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. |
POST / HTTP/1.1
Host: ocr.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: RecognizeMainlandIDCardOCR
<common request parameters>
{
"ImageBase64": "/9j/4AAQSkZJRg.....s97n//2Q=="
}
{
"Response": {
"Address": "abc",
"Authority": "",
"Birth": "abc",
"IdCardImage": "",
"IdNum": "41290*******291716",
"Name": "abc",
"Nation": "abc",
"PortraitImage": "",
"RequestId": "8c051b49-2ff8-4e41-971e-1a7cf37bbab5",
"Sex": "abc",
"ValidDate": "",
"WarnCardInfos": [
-9101
]
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
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.CardSideError | The CardSide type of the ID card is incorrect. |
| FailedOperation.DownLoadError | Failed to download the file. |
| FailedOperation.EmptyImageError | The image is empty. |
| FailedOperation.IdCardInfoIllegal | The ID card information (ID number, name, etc.) is invalid. |
| FailedOperation.IdCardTooSmall | The resolution of the image is too low or the proportion of the ID card in the image is too small. |
| FailedOperation.ImageBlur | The image is blurry. |
| FailedOperation.ImageDecodeFailed | Failed to decode the image. |
| FailedOperation.ImageNoIdCard | No ID card is detected in the image. |
| FailedOperation.ImageSizeTooLarge | The image size exceeds the limit. Refer to the image size constraints in the input parameter description. |
| FailedOperation.MultiCardError | Multiple cards of the same side are detected in the image. Please upload an image with a single side or one front and one back side. |
| 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 |
| ResourceUnavailable.InArrears | The account has insufficient balance. |
| ResourceUnavailable.ResourcePackageRunOut | The resource package has been exhausted. |
| ResourcesSoldOut.ChargeStatusException | The billing status is abnormal. |
文档反馈