May 20, 2021 WeChat Mini Program Development Document
This interface should be called on the server side, as detailed in the Service Side API.
This interface supports cloud calls. Developer tool version required . . . 1.02.1904090 (latest stable download)
wx-server-sdk >= 0.4.0
This interface provides OCR identification of business licenses based on small programs
How to call:
POST https://api.weixin.qq.com/cv/ocr/bizlicense?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
img_url | string | Is | To detect the picture url, pass this without passing the img parameter. | |
Img | FormData | Is | Form-data media file identification, there is fileame, filelength, content-type and other information, pass this without passing img_url. |
The returned JSON packet
Property | Type | Description |
---|---|---|
errcode | string | Error code |
errmsg | string | The error message |
reg_num | string | Registration number |
serial | string | Number |
legal_representative | string | The name of the legal representative |
enterprise_name | string | The name of the business |
type_of_organization | string | Form of composition |
address | string | Business premises/business residences |
type_of_enterprise | string | The type of company |
business_scope | string | Business scope |
registered_capital | string | Registered capital |
paid_in_capital | string | Pay-as-you-go capital |
valid_period | string | The term of business |
registered_date | string | Registration date/establishment date |
cert_position | string | Business license location |
img_size | string | The size of the picture |
Interface limits the certified subscription number, service number, enterprise number, and applet during the internal test, and the number of times is limited to 500 times / day.
Using TIPS This interface is a background interface, you can use the self-service bearer case, with a small program, the photo album selection, etc. can complete the collection, upload, identification, information return and other processes, for needBusiness scenes such as identity cards, bank cards or other physical cards or certificates, collect photos or text messages, etc.
Image Description File size limit: less than 2m
The return field contains only the fields that exist in the current business license picture and is not returned if the corresponding field does not exist
Take a picture sample
Example 1:
curl https://api.weixin.qq.com/cv/ocr/bizlicense?img_url= ENCODE_URL&access_token=ACCESS_TOCKEN
Example 2:
curl -F ‘[email protected]’“https://api.weixin.qq.com/cv/ocr/bizlicense?access_token=ACCESS_TOCKEN”
{
"errcode": 0,
"errmsg": "ok",
"reg_num": "123123", //注册号
"serial": "123123", //编号
"legal_representative": "张三", //法定代表人姓名
"enterprise_name": "XX饮食店", //企业名称
"type_of_organization": "个人经营", //组成形式
"address": "XX市XX区XX路XX号", //经营场所/企业住所
"type_of_enterprise": "xxx", //公司类型
"business_scope": "中型餐馆(不含凉菜、不含裱花蛋糕,不含生食海产品)。", //经营范围
"registered_capital": "200万", //注册资本
"paid_in_capital": "200万", //实收资本
"valid_period": "2019年1月1日", //营业期限
"registered_date": "2018年1月1日", //注册日期/成立日期
"cert_position": { //营业执照位置
"pos": {
"left_top": {
"x": 155,
"y": 191
},
"right_top": {
"x": 725,
"y": 157
},
"right_bottom": {
"x": 743,
"y": 512
},
"left_bottom": {
"x": 164,
"y": 525
}
}
},
"img_size": { //图片大小
"w": 966,
"h": 728
}
}
Cloud call is the ability provided by the small program Cloud Development to call WeChat open interfaces in cloud functions and need to be used in cloud functions via wx-server-sdk.
openapi.ocr.businessLicense
Permissions for the ocr.businessLicense API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
imgUrl | string | Is | To detect the picture url, pass this without passing the img parameter. | |
Img | FormData | Is | Form-data media file identification, there is fileame, filelength, content-type and other information, pass this without passing img_url. |
The structure of img
Property | Type | The default | Required | Description |
---|---|---|---|---|
contentType | string | Is | Data type, incoming MIME Type | |
value | Buffer | Is | File Buffer |
The returned JSON packet
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
regNum | string | Registration number |
serial | string | Number |
legalRepresentative | string | The name of the legal representative |
enterpriseName | string | The name of the business |
typeOfOrganization | string | Form of composition |
address | string | Business premises/business residences |
typeOfEnterprise | string | The type of company |
businessScope | string | Business scope |
registeredCapital | string | Registered capital |
paidInCapital | string | Pay-as-you-go capital |
validPeriod | string | The term of business |
registeredDate | string | Registration date/establishment date |
certPosition | string | Business license location |
imgSize | string | The size of the picture |
The exception thrown
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
The legal value of errCode
Value | Description | The lowest version |
---|
Interface Limits Subscription numbers, service numbers, enterprise numbers, and small programs that have been certified during the internal test can be called directly, with a limit of 500 times per day.
Using Tips this interface for the background interface, can be based on its own business hosting situation, with small programs of photography, photo selection, etc. together, you can complete the ID photo collection, upload, identification, information return and other processes, for the need to be based on identity cards, bank cards and other physical cards or certificates, collection of photos or text information and other business scenarios.
Image caption File size limit: less than 2M
The return field contains only the fields that exist in the current business license picture and is not returned if the corresponding field does not exist
Take a picture sample
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.ocr.businessLicense({
imgUrl: 'ENCODE_URL'
})
return result
} catch (err) {
return err
}
}
Or
// cloud = require('wx-server-sdk')
// ...
// 方法返回 Promise
cloud.openapi.ocr.businessLicense({
img: {
contentType: 'image/png',
value: Buffer
}
})
{
"errcode": 0,
"errmsg": "ok",
"reg_num": "123123", //注册号
"serial": "123123", //编号
"legal_representative": "张三", //法定代表人姓名
"enterprise_name": "XX饮食店", //企业名称
"type_of_organization": "个人经营", //组成形式
"address": "XX市XX区XX路XX号", //经营场所/企业住所
"type_of_enterprise": "xxx", //公司类型
"business_scope": "中型餐馆(不含凉菜、不含裱花蛋糕,不含生食海产品)。", //经营范围
"registered_capital": "200万", //注册资本
"paid_in_capital": "200万", //实收资本
"valid_period": "2019年1月1日", //营业期限
"registered_date": "2018年1月1日", //注册日期/成立日期
"cert_position": { //营业执照位置
"pos": {
"left_top": {
"x": 155,
"y": 191
},
"right_top": {
"x": 725,
"y": 157
},
"right_bottom": {
"x": 743,
"y": 512
},
"left_bottom": {
"x": 164,
"y": 525
}
}
},
"img_size": { //图片大小
"w": 966,
"h": 728
}
}