ID Card Portrait Photo Verification API Integration Guide

This document introduces an ID Card Portrait Photo Verification API integration guide. It can be used to submit a photo of the portrait side of an ID card, recognize the information on the ID card, and compare the name, ID card number, and ID card portrait photo with the ID photo in an authoritative database to determine whether they belong to the same person, thereby verifying the authenticity of the ID card information.

Application Process

To use the ID Card Portrait Photo Verification API, first go to the Ace Data Cloud Console to obtain your API Token for later use.

If you have not yet logged in or registered, you will be automatically redirected to the login page to register and log in. Once completed, you will be automatically returned to the current page.

A general application's API Key can be used for services enabled for the account; a dedicated application's Key can be used within that application's service scope. Please check the Key's permissions, validity period, and limits, and confirm that the application balance is sufficient to pay for this request. Available trial credits are subject to what is displayed in your account. If the balance is insufficient, click the "Recharge" button.

📘 Full documentation: ID Card Portrait Photo Verification API →

Basic Usage

First, let's look at the basic usage: enter an ID card image URL to obtain the verification result after processing. First, simply pass an image_url field, then fill in the corresponding content in the interface, as shown below:

As you can see, we have set the Request Headers here, including:

  • accept: The format in which you want to receive the response. Here it is set to application/json, namely JSON format.
  • authorization: The key used to call the API. After applying for it, you can select it directly from the dropdown.

We have also set the Request Body, including:

  • image_url: The URL of the ID card image to be processed.
  • config: Optional configuration items. Boolean fields default to false. Supported items include copy_warn, border_check_warn, reshoot_warn, detect_ps_warn, temp_id_warn, and quality (threshold 0–100).

After making the selections, you can see that the corresponding code has also been generated on the right, as shown below:

Click the "Try" button to test it. As shown above, we obtained the following result:

{
  "sim": 99.76,
  "result": "Success",
  "description": "成功",
  "name": "身份证姓名",
  "sex": "身份证性别",
  "nation": "身份证民族",
  "birth": "身份证生日",
  "address": "身份证家庭住址",
  "id_num": "身份证号码",
  "portrait": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBA.....DEhE2lbPMcOtG3f/DLT/yX8if7Kxn/AD7h85wdttPifRf1e6//2Q==",
  "warnings": "",
  "quality": 0,
  "encryption": null
}

The returned result contains multiple fields, described as follows:

  • sim, similarity, with a value range of [0.00, 100.00]. A similarity of 70 or higher is recommended for determining that the subjects are the same person. You can adjust the threshold according to the specific scenario (the false acceptance rate at a threshold of 70 is one in a thousand, and at a threshold of 80 it is one in ten thousand).
  • result, the business error code. Success is returned on success. For errors, refer to the FailedOperation section in the error code list below.
  • description, the result of the name and ID card number verification.
  • name, the name on the ID card. It is empty if no ID card image was uploaded.
  • sex, the sex on the ID card. It is empty if no ID card image was uploaded.
  • nation, the ethnicity on the ID card. It is empty if no ID card image was uploaded.
  • birth, the date of birth on the ID card. It is empty if no ID card image was uploaded.
  • address, the home address on the ID card. It is empty if no ID card image was uploaded.
  • id_num, the ID card number on the ID card. It is empty if no ID card image was uploaded.
  • portrait, the Base64 encoding of the ID card portrait photo. If portrait extraction fails, the entire ID card image is used for comparison and an empty value is returned.
  • warnings, warning information. When warnings are configured in Config, portrait comparison will stop, Result will return an error (FailedOperation.OcrWarningOccurred), and this warning information will be included.
  • quality, the image quality score. This parameter is only meaningful when the image blur warning is configured in the request Config. Its value range is 0–100. The current default threshold is 50 points; a score below 50 will trigger a blur warning.
  • encryption, sensitive data encryption information.

As can be seen, the ID card information has a high degree of authenticity.

In addition, if you want to generate the corresponding integration code, you can copy the generated code directly. For example, the CURL code is as follows:

curl -X POST 'https://api.acedata.cloud/identity/idcard/check-1e' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "image_url": {image_url}
}'

The Python integration code is as follows:

import requests

url = "https://api.acedata.cloud/identity/idcard/check-1e"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "image_url": {image_url}
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)

Error Handling

When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:

  • 400 token_mismatched: Bad request, possibly due to missing or invalid parameters.
  • 400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.
  • 401 invalid_token: Unauthorized, invalid or missing authorization token.
  • 429 too_many_requests: Too many requests, you have exceeded the rate limit.
  • 500 api_error: Internal server error, something went wrong on the server.

Error Response Example

{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}

Conclusion

Through this document, you have learned how to use the ID Card Portrait Photo Verification API to submit a photo of the portrait side of an ID card, recognize the information on the ID card, and compare the name, ID card number, and ID card portrait photo with the ID photo in an authoritative database to determine whether they belong to the same person, thereby verifying the authenticity of the ID card information. We hope this document helps you better integrate and use the API. If you have any questions, please feel free to contact our technical support team.