Skip to main content
This document will introduce an ID card portrait photo verification API integration instruction, which can be used to input the portrait photo of an ID card, recognize the information on the ID card photo, and compare the name, ID number, and portrait photo with the authoritative database to determine if they belong to the same person, thereby verifying the authenticity of the ID card information.

Application Process

To use the API, you need to first apply for the corresponding service on the ID Card Portrait Photo Verification API page. After entering the page, click the “Acquire” button, as shown in the figure: If you are not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in. After logging in or registering, you will be automatically returned to the current page. There will be a free quota granted for the first application, allowing you to use the API for free.

Basic Usage

First, understand the basic usage method, which is to input the ID card image link to obtain the processed verification result. You need to simply pass a image_url field, and we can then fill in the corresponding content on the interface, as shown in the figure:

Here we can see that we have set the Request Headers, including:
  • accept: the format of the response result you want to receive, here filled in as application/json, which is in JSON format.
  • authorization: the key to call the API, which can be directly selected after application.
Additionally, the Request Body is set, including:
  • image_url: the link to the ID card image that needs to be processed.
  • config: optional configuration items, boolean fields, all default to false, supporting copy_warn, border_check_warn, reshoot_warn, detect_ps_warn, temp_id_warn, quality (threshold 0-100).
After selection, you can find that the corresponding code is also generated on the right side, as shown in the figure:

Click the “Try” button to conduct a test, as shown in the above figure, and 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]. It is recommended that a similarity of 70 or above can be judged as the same person, and the threshold can be adjusted according to specific scenarios (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: business error code, returns “Success” for successful cases; for error cases, please refer to the FailedOperation section in the error code list below.
  • description: the result of the verification of the name and ID number here.
  • name: the name information in the ID card; it will be empty if no ID card image is uploaded.
  • sex: the gender information in the ID card; it will be empty if no ID card image is uploaded.
  • nation: the ethnic information in the ID card; it will be empty if no ID card image is uploaded.
  • birth: the birthday information in the ID card; it will be empty if no ID card image is uploaded.
  • address: the home address information in the ID card; it will be empty if no ID card image is uploaded.
  • id_num: the ID number information in the ID card; it will be empty if no ID card image is uploaded.
  • portrait: the base64 encoding of the ID card portrait photo; if the cropping fails, the entire ID card will be used for comparison and return empty.
  • warnings: warning information; when warning information is configured in Config, the portrait comparison will stop, and the Result will return an error (FailedOperation.OcrWarningOccurred) along with this warning information.
  • quality: image quality score; this parameter is meaningful only when the image blur warning is configured in the request Config, with a value range of (0-100). The current default threshold is 50 points; below 50 points will trigger a blur warning.
  • encryption: sensitive data encryption information.
It can be seen that the ID card information has a high degree of authenticity. Additionally, if you want to generate the corresponding integration code, you can directly copy it, 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 input the portrait photo of an ID card, recognize the information on the ID card photo, and compare the name, ID number, and portrait photo with the authoritative database to determine if they belong to the same person, thereby verifying the authenticity of the ID card information. We hope this document can help you better integrate and use the API. If you have any questions, please feel free to contact our technical support team.