1. API Description

1.1 Feature

This API provides OCR recognition for ID cards, bank cards, and driver's licenses based on Mini Programs or HTML5.

1.2 API Limits

This API requires the appid of the relevant Mini Program/Official Account and can only be called after the permission is activated.

To apply for the permission, send an email containing the appid of the relevant Mini Program or Official Account and the usage/reason description to the Tencent's work email wx_city@tencent.com. You will receive a reply email after the API permission is activated.

The following is the application email template:

Email title:

[WeChat  OCR] Application for ID card recognition API permission

Email message:

1. The  appid of the Official Account or Mini Program that needs to apply for the WeChat  OCR  ID card recognition API permission:

2. Usage/reason description:

1.3 Tips This API is a backend API and can be used in conjunction with the "Camera" or "Album" module of Mini Programs or HTML5 pages based on the hosted self-developed businesses to collect, upload, and recognize the ID card photos, and return information. It is mainly applied in business scenarios where photos or text information needs to be collected based on ID cards, bank cards, and other physical cards or credentials.

2. ID Card OCR Recognition API

2.1 Request Example

URL:
http://api.weixin.qq.com/cv/ocr/idcard?type=MODE&img_url=ENCODE_URL&access_token=ACCESS_TOCKEN
Example 1:
curl http://api.weixin.qq.com/cv/ocr/idcard?type=photo&img_url= ENCODE_URL&access_token=ACCESS_TOCKEN
Example 2:
curl -F 'img=@test.jpg'"http://api.weixin.qq.com/cv/ocr/idcard?type=photo&img_url= ENCODE_URL&access_token=ACCESS_TOCKEN"

Notes: You can use the img parameter to upload the image in real time and the img_url parameter to transfer the image URL, and the WeChat backend will download and recognize the image. There are two options for "type":

photo: The photo taking mode, suitable for images with background (see the example below)

scan: The scanning mode, suitable for images without background (see the example below)

The file size should be less than 2 MB.

Note: To get an access token, refer to the WeChat Official Accounts Platform Open API documentation: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183

2.2 Sample of Response Parameters




3. Bank Card OCR Recognition API

3.1 Request Example

URL:
http://api.weixin.qq.com/cv/ocr/ bankcard? img_url=ENCODE_URL&access_token=ACCESS_TOCKEN
Example 1:
curl http://api.weixin.qq.com/cv/ocr/ bankcard?img_url= ENCODE_URL&access_token=ACCESS_TOCKEN
Example 2:
curl -F 'img=@test.jpg'"http://api.weixin.qq.com/cv/ocr/ bankcard? img_url= ENCODE_URL&access_token=ACCESS_TOCKEN"

Notes:

The file size should be less than 2 MB.

Sample photo:

3.2 Sample of Response Parameters

4. Driver's License OCR Recognition API

URL:
http://api.weixin.qq.com/cv/ocr/ driving? img_url=ENCODE_URL&access_token=ACCESS_TOCKEN
Example 1:
curl http://api.weixin.qq.com/cv/ocr/ driving?img_url= ENCODE_URL&access_token=ACCESS_TOCKEN
Example 2:
curl -F 'img=@test.jpg'"http://api.weixin.qq.com/cv/ocr/ driving? img_url= ENCODE_URL&access_token=ACCESS_TOCKEN"

Notes: The file size should be less than 2 MB. Sample photo:

4.2 Sample of Response Parameters

{
"errcode": 0,
"errmsg": "ok",
"plate_num": "粤xxxxx",
"vehicle_type": "Small ordinary passenger car⻋",
"owner": "Dongguan xxxxx Machinery Factory",
"addr": "No. xxxxx, Dongguan, Guangdong",
"use_character": "Non-commercial",
"model": "JAC HFCxxxxxxx",
"vin": "LJ166xxxxxxxx51",
"engine_num": "J3xxxxx3",
"register_date": "2018-07-06",
"issue_date": "2018-07-01",
"plate_num_b": "粤xxxxx",
"record": "441xxxxxx3",
"passengers_num": "7 people",
"total_quality": "2700kg",
"prepare_quality": "1995kg"
}