
营业执照OCR识别
企业用户实名使用个人用户实名使用个人用户无法使用
传入营业执照图片或url地址,识别营业执照基本信息
价格
¥0元/20次
新用户免费体验,自购买起有效期1个月
选择套餐:

接口名称:营业执照OCR识别
描述:上传营业执照照片,扫描文字返回文字信息
请求地址 url:https://api.shuxuntech.com/v1/business/ocr
请求方式 method:post
请求Content-Type: application/x-www-form-urlencoded
参数:
| 名称 | 参数位置 | 类型 | 是否必填 | 说明 |
|---|---|---|---|---|
| appKey | head | string | 是 | 数勋分配appKey |
| timestamp | head | string | 是 | unix时间毫秒值 |
| sign | head | string | 是 | 签名,说明 |
| image | body | string | 否 | 营业执照照片base64,不超过1mb |
| imgUrl | body | string | 否 | 营业执照图片url,不超过1mb |
签名算法说明:
数勋分配的appKey、当前unix时间毫秒值timestamp、数勋分配的appSecret、 按顺序拼接sha256加密得到sign,查看如下示例
appKey = aaa;
timestamp = 1682476904289;
appSecret = bbb;
sign = sha256(appKey+timestamp+appSecret)
正确返回:
{
"code": "0",
"msg": "成功",
"isFee": 1,
"seqNo": "98ik48a942udag92uxvhz1jw2txplza9",
"data": {
"result": 1,
"resultDesc": "识别成功,有数据",
"info": {
"enterpriseType": "有限责任公司(自然人投资或控股)",
"address": "北京市**区西二旗***3号院**号***号",
"registrationCapital": "185,000万(元)",
"opTo": "",
"orgForm": "",
"opScope": "一般项目:技术服务、技术开发、技术咨询、技术交流、技术转让、技术推广;货物进出口;技术进出口;进出口代理;通讯设备销售;厨具卫具及日用杂品批发;厨具卫具及日用杂品零售;个人卫生用品销售;卫生用品和一次性使用医疗用品销售;日用杂品销售;日用百货销售;日用品销售;化妆品批发;化妆品零售;第一类医疗器械销售;第二类医疗器械销售;玩具销售;体育用品及器材零售;体育用品及器材批发;文具用品零售;文具用品批发;鞋帽批发;鞋帽零售;服装服饰批发;服装服饰零售;钟表销售;眼镜销售(不含隐形眼镜);针纺织品销售;家用电器销售;日用家电零售;家具销售;礼品花卉销售;农作物种子经营(仅限不再分装的包装种子);照相机及器材销售;照相器材及望远镜批发;照相器材及望远镜零售;工艺美术品及收藏品零售(象牙及其制品除外);工艺美术品及礼仪用品销售(象牙及其制品除外);计算机软硬件及辅助设备零售;计算机软硬件及辅助设备批发;珠宝首饰零售;珠宝首饰批发;食用农产品批发;食用农产品零售;宠物食品及用品批发;宠物食品及用品零售;电子产品销售;摩托车及零配件零售;摩托车及零配件批发;电动自行车销售;助动自行车、代步车及零配件销售;自行车及零配件零售;自行车及零配件批发;单用途商业预付卡代理销售;商用密码产品销售;五金产品批发;五金产品零售;建筑材料销售;仪器仪表修理;计算机及办公设备维修;办公设备销售;会议及展览服务;组织文化艺术交流活动;广告设计、代理;广告制作;广告发布;摄影扩印服务;票务代理服务;通讯设备修理;移动终端设备制造;可穿戴智能设备制造。(除依法须经批准的项目外,凭营业执照依法自主开展经营活动)许可项目:第三类医疗器械经营;网络文化经营;出版物零售;出版物批发;食品销售;药品零售;广播电视节目制作经营;第一类增值电信业务;第二类增值电信业务;在线数据处理与交易处理业务(经营类电子商务);基础电信业务;互联网信息服务;信息网络传播视听节目。(依法须经批准的项目,经相关部门批准后方可开展经营活动,具体经营项目以相关部门批准文件或许可证件为准)(不得从事国家和本市产业政策禁止和限制类项目的经营活动。)",
"establishingDate": "2010-03-03",
"legalName": "***",
"registrationCode": "",
"opFrom": "",
"creditCode": "9111010855***082Q",
"opPeriod": "",
"enterpriseName": "***科技有限责任公司",
"isCopy": 1
}
}
}
错误返回:
{
"code": "1",
"msg": "参数错误",
"isFee": 0,
"seqNo": null,
"data": null
}
返回字段描述:
| 字段名 | 类型 | 描述 |
|---|---|---|
| code | string | 错误码 |
| msg | string | 错误描述 |
| isFee | int | 是否计费(1:计费,0:不计费) |
| seqNo | string | 调用流水号 |
| data | object | 返回数据 |
data对象说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| result | int | 识别结果 |
| resultDesc | string | 识别结果描述 |
| info | object | 营业执照信息 |
info对象说明
| 字段名 | 类型 | 描述 |
|---|---|---|
| enterpriseType | string | 企业类型 |
| address | string | 地址 |
| registrationCapital | string | 注册资本 |
| opTo | string | 经营结束日期 |
| orgForm | string | 组成形式 |
| opScope | string | 经营范围 |
| establishingDate | string | 成立时间 |
| legalName | string | 企业法人 |
| registrationCode | string | 注册号 |
| opFrom | string | 经营开始日期 |
| creditCode | string | 统一社会信用代码 |
| opPeriod | string | 经营日期开始至结束时间 |
| enterpriseName | string | 企业名称 |
| isCopy | int | 是否为副本, 1:是 0:否 |
result扫描结果说明
| 字段值 | 描述 |
|---|---|
| 1 | 识别成功,有数据 |
| 2 | 识别成功,无数据 |
| 3 | 识别失败,无法正确解析、未按要求传入参数、下载图片超时 |
code错误码说明
| code | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 参数错误 |
| 2 | 无记录 |
| 3 | 第三方服务异常 |
| 4 | 签名错误 |
| 5 | 余额不足 |
| 6 | 调用频率超限 |
| 7 | 账号停用 |
| 8 | 接口已停用 |
| 9 | 联系服务商开通接口权限 |
| 10 | ip不在白名单 |
| 11 | 系统异常 |
| 12 | 实名状态错误 |
| 99 | 其他异常,具体返回为准 |
营业执照OCR
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.MessageDigest;
/**
* 营业执照OCR - Java 示例代码
* 接口地址:https://api.shuxuntech.com/v1/business/ocr
*
* 说明:本示例只使用 JDK 原生 API(java.net / java.security),不依赖任何第三方 jar 包,
* 也不需要本项目的工具类,复制到本地即可编译运行:
* javac BusinessOcrDemo.java
* java BusinessOcrDemo
*/
public class BusinessOcrDemo {
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private static final String APP_KEY = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private static final String APP_SECRET = "您的appSecret";
/** 接口地址 */
private static final String API_URL = "https://api.shuxuntech.com/v1/business/ocr";
/** 图片base64 */
private static final String IMAGE = "";
/** 图片url */
private static final String IMG_URL = "";
public static void main(String[] args) throws Exception {
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
String timestamp = String.valueOf(System.currentTimeMillis());
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256,得到小写十六进制字符串
String sign = sha256Hex(APP_KEY + timestamp + APP_SECRET);
// 3、业务参数,拼成表单内容
String body = "image=" + urlEncode(IMAGE) + "&" + "imgUrl=" + urlEncode(IMG_URL);
// 4、发起 POST 请求,appKey、timestamp、sign 放在请求头
HttpURLConnection conn = (HttpURLConnection) new URL(API_URL).openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
conn.setRequestProperty("appKey", APP_KEY);
conn.setRequestProperty("timestamp", timestamp);
conn.setRequestProperty("sign", sign);
conn.setConnectTimeout(10000);
conn.setReadTimeout(20000);
conn.getOutputStream().write(body.getBytes("UTF-8"));
int status = conn.getResponseCode();
// 5、读取返回内容:报错时读错误流,避免只拿到一个异常看不到原因
InputStream in = (status >= 200 && status < 300) ? conn.getInputStream() : conn.getErrorStream();
String result = readAll(in);
conn.disconnect();
System.out.println("HTTP状态码=" + status);
System.out.println("返回结果=" + result);
}
/**
* sha256 加密,返回小写十六进制字符串
* 服务端校验签名用的就是这个算法(小写十六进制)
*/
private static String sha256Hex(String content) throws Exception {
byte[] bytes = MessageDigest.getInstance("SHA-256").digest(content.getBytes("UTF-8"));
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
sb.append(Character.forDigit((b >> 4) & 0xF, 16));
sb.append(Character.forDigit(b & 0xF, 16));
}
return sb.toString();
}
/** url 编码,中文参数需要编码 */
private static String urlEncode(String value) throws Exception {
return URLEncoder.encode(value, "UTF-8");
}
/** 读取输入流内容 */
private static String readAll(InputStream in) throws Exception {
if (in == null) {
return "";
}
StringBuilder sb = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
try {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} finally {
reader.close();
}
return sb.toString();
}
}
# 营业执照OCR - Python 示例代码
# 接口地址:https://api.shuxuntech.com/v1/business/ocr
#
# 说明:只使用 Python 标准库(urllib / hashlib / time),不需要 pip 安装任何第三方包,
# 保存为 business_ocr_demo.py 后直接执行 python business_ocr_demo.py 即可。
import hashlib
import time
import urllib.error
import urllib.parse
import urllib.request
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY = "您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET = "您的appSecret"
# 接口地址
API_URL = "https://api.shuxuntech.com/v1/business/ocr"
# 图片base64
IMAGE = ""
# 图片url
IMG_URL = ""
def sha256_hex(content):
"""sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法"""
return hashlib.sha256(content.encode("utf-8")).hexdigest()
def main():
# 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
timestamp = str(int(time.time() * 1000))
# 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
sign = sha256_hex(APP_KEY + timestamp + APP_SECRET)
# 3、业务参数
params = {}
params["image"] = IMAGE
params["imgUrl"] = IMG_URL
data = urllib.parse.urlencode(params)
# 4、发起 POST 请求,appKey、timestamp、sign 放在请求头
request = urllib.request.Request(API_URL, data=data.encode("utf-8"), method="POST")
request.add_header("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
request.add_header("appKey", APP_KEY)
request.add_header("timestamp", timestamp)
request.add_header("sign", sign)
# 5、读取返回内容:报错时也把返回体读出来,避免只拿到一个异常看不到原因
try:
with urllib.request.urlopen(request, timeout=20) as response:
status = response.getcode()
body = response.read().decode("utf-8")
except urllib.error.HTTPError as e:
status = e.code
body = e.read().decode("utf-8")
print("HTTP状态码=" + str(status))
print("返回结果=" + body)
if __name__ == "__main__":
main()
<?php
/**
* 营业执照OCR - PHP 示例代码
* 接口地址:https://api.shuxuntech.com/v1/business/ocr
*
* 说明:只使用 PHP 内置函数,不需要 composer 安装任何依赖,也不需要 curl 扩展,
* 保存为 business_ocr_demo.php 后直接执行 php business_ocr_demo.php 即可。
*/
// 数勋分配的 appKey,请替换为您自己的 appKey
$appKey = "您的appKey";
// 数勋分配的 appSecret,请替换为您自己的 appSecret
$appSecret = "您的appSecret";
// 接口地址
$url = "https://api.shuxuntech.com/v1/business/ocr";
// 图片base64
$image = "";
// 图片url
$imgUrl = "";
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
$timestamp = sprintf('%.0f', microtime(true) * 1000);
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
$sign = hash('sha256', $appKey . $timestamp . $appSecret);
// 3、业务参数
$params = array(
'image' => $image,
'imgUrl' => $imgUrl,
);
$body = http_build_query($params);
// 4、发起 POST 请求,appKey、timestamp、sign 放在请求头
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"
. "appKey: {$appKey}\r\n"
. "timestamp: {$timestamp}\r\n"
. "sign: {$sign}\r\n",
'content' => $body,
'timeout' => 20,
// 返回 4xx、5xx 时也把返回体读出来,方便排查
'ignore_errors' => true,
),
));
$result = file_get_contents($url, false, $context);
// 打印结果
if (!empty($http_response_header[0])) {
echo "HTTP状态=" . $http_response_header[0] . PHP_EOL;
}
echo "返回结果=" . $result . PHP_EOL;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
/**
* 营业执照OCR - C# 示例代码
* 接口地址:https://api.shuxuntech.com/v1/business/ocr
*
* 说明:只使用 .NET 基础类库(System.Net.Http / System.Security.Cryptography),不依赖任何第三方包。
* 需要 .NET Framework 4.5 及以上,或 .NET Core / .NET 5 及以上;
* 保存为 BusinessOcrDemo.cs 后,用 dotnet run 或 VS 控制台项目直接运行即可。
*/
public class BusinessOcrDemo
{
/** 数勋分配的 appKey,请替换为您自己的 appKey */
private const string AppKey = "您的appKey";
/** 数勋分配的 appSecret,请替换为您自己的 appSecret */
private const string AppSecret = "您的appSecret";
/** 接口地址 */
private const string ApiUrl = "https://api.shuxuntech.com/v1/business/ocr";
/** 图片base64 */
private const string Image = "";
/** 图片url */
private const string ImgUrl = "";
public static void Main(string[] args)
{
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
long millis = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
string timestamp = millis.ToString();
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
string sign = Sha256Hex(AppKey + timestamp + AppSecret);
// 3、业务参数
Dictionary<string, string> form = new Dictionary<string, string>();
form.Add("image", Image);
form.Add("imgUrl", ImgUrl);
string body = ToFormBody(form);
// 4、发起 POST 请求,appKey、timestamp、sign 放在请求头
using (HttpClient client = new HttpClient())
{
client.Timeout = TimeSpan.FromSeconds(20);
client.DefaultRequestHeaders.Add("appKey", AppKey);
client.DefaultRequestHeaders.Add("timestamp", timestamp);
client.DefaultRequestHeaders.Add("sign", sign);
StringContent content = new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded");
HttpResponseMessage response = client.PostAsync(ApiUrl, content).GetAwaiter().GetResult();
// 5、读取返回内容,4xx、5xx 时 HttpClient 不会抛异常,这里同样能拿到返回体
string resultText = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
Console.WriteLine("HTTP状态码=" + (int)response.StatusCode);
Console.WriteLine("返回结果=" + resultText);
}
}
/** 拼装 application/x-www-form-urlencoded 内容,中文参数需要编码 */
private static string ToFormBody(Dictionary<string, string> form)
{
StringBuilder sb = new StringBuilder();
foreach (KeyValuePair<string, string> item in form)
{
if (sb.Length > 0)
{
sb.Append("&");
}
sb.Append(Uri.EscapeDataString(item.Key)).Append("=").Append(Uri.EscapeDataString(item.Value));
}
return sb.ToString();
}
/** sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法 */
private static string Sha256Hex(string content)
{
using (SHA256 sha256 = SHA256.Create())
{
byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(content));
StringBuilder sb = new StringBuilder(bytes.Length * 2);
foreach (byte b in bytes)
{
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
}
}
// 营业执照OCR - Node.js 示例代码
// 接口地址:https://api.shuxuntech.com/v1/business/ocr
//
// 说明:只使用 Node.js 内置模块(https / crypto),不需要 npm 安装任何第三方包,
// 保存为 business_ocr_demo.js 后直接执行 node business_ocr_demo.js 即可(需 Node 10 及以上)。
const https = require('https');
const crypto = require('crypto');
// 数勋分配的 appKey,请替换为您自己的 appKey
const APP_KEY = '您的appKey';
// 数勋分配的 appSecret,请替换为您自己的 appSecret
const APP_SECRET = '您的appSecret';
// 接口地址
const API_URL = 'https://api.shuxuntech.com/v1/business/ocr';
// 图片base64
const IMAGE = '';
// 图片url
const IMG_URL = '';
// sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法
function sha256Hex(content) {
return crypto.createHash('sha256').update(content, 'utf8').digest('hex');
}
// 打印返回结果
function printResult(statusCode, body) {
console.log('HTTP状态码=' + statusCode);
console.log('返回结果=' + body);
}
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
const timestamp = String(Date.now());
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
const sign = sha256Hex(APP_KEY + timestamp + APP_SECRET);
// 3、业务参数,放在请求体里(中文由 URLSearchParams 自动 URL 编码)
const body = new URLSearchParams({ image: IMAGE, imgUrl: IMG_URL }).toString();
// 4、发起 POST 请求,appKey、timestamp、sign 放在请求头
const request = https.request(API_URL, {
method: 'POST',
headers: {
appKey: APP_KEY,
timestamp: timestamp,
sign: sign,
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Content-Length': Buffer.byteLength(body)
},
timeout: 20000
}, function (response) {
// 5、读取返回内容:即使报错(4xx、5xx)也能拿到返回体,避免只看到异常看不到原因
let respBody = '';
response.setEncoding('utf8');
response.on('data', function (chunk) { respBody += chunk; });
response.on('end', function () { printResult(response.statusCode, respBody); });
});
request.on('timeout', function () {
request.destroy();
console.log('请求超时');
});
request.on('error', function (err) {
console.log('请求异常=' + err.message);
});
request.write(body);
request.end();
// 营业执照OCR - Go 示例代码
// 接口地址:https://api.shuxuntech.com/v1/business/ocr
//
// 说明:只使用 Go 标准库(net/http、crypto/sha256、encoding/hex 等),不需要引入任何第三方包,
// 保存为 business_ocr_demo.go 后直接执行 go run business_ocr_demo.go 即可。
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
)
// 数勋分配的 appKey,请替换为您自己的 appKey
const appKey = "您的appKey"
// 数勋分配的 appSecret,请替换为您自己的 appSecret
const appSecret = "您的appSecret"
// 接口地址
const apiURL = "https://api.shuxuntech.com/v1/business/ocr"
// 图片base64
const image = ""
// 图片url
const imgUrl = ""
// sha256 加密,返回小写十六进制字符串,服务端校验签名用的就是这个算法
func sha256Hex(content string) string {
sum := sha256.Sum256([]byte(content))
return hex.EncodeToString(sum[:])
}
func main() {
// 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
timestamp := fmt.Sprintf("%d", time.Now().UnixNano()/int64(time.Millisecond))
// 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256
sign := sha256Hex(appKey + timestamp + appSecret)
// 3、业务参数,放在请求体里(url.Values 会自动对中文做 URL 编码)
form := url.Values{}
form.Set("image", image)
form.Set("imgUrl", imgUrl)
requestBody := form.Encode()
// 4、发起 POST 请求,appKey、timestamp、sign 放在请求头
req, err := http.NewRequest("POST", apiURL, strings.NewReader(requestBody))
if err != nil {
fmt.Println("创建请求失败=" + err.Error())
return
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
req.Header.Set("appKey", appKey)
req.Header.Set("timestamp", timestamp)
req.Header.Set("sign", sign)
client := &http.Client{Timeout: 20 * time.Second}
resp, err := client.Do(req)
if err != nil {
fmt.Println("请求异常=" + err.Error())
return
}
defer resp.Body.Close()
// 5、读取返回内容:即使报错(4xx、5xx)也能拿到返回体
body, _ := io.ReadAll(resp.Body)
fmt.Println("HTTP状态码=" + resp.Status)
fmt.Println("返回结果=" + string(body))
}
#!/usr/bin/env bash
# 营业执照OCR - curl 示例代码
# 接口地址:https://api.shuxuntech.com/v1/business/ocr
#
# 说明:只依赖系统自带的 curl 和 openssl(用于计算 sha256),不需要安装任何第三方工具,
# 保存为 business_ocr_demo.sh 后直接执行 bash business_ocr_demo.sh 即可。
# 如果系统没有 openssl,可把下面 SIGN 那一行换成注释里的 sha256sum 写法。
# 数勋分配的 appKey,请替换为您自己的 appKey
APP_KEY="您的appKey"
# 数勋分配的 appSecret,请替换为您自己的 appSecret
APP_SECRET="您的appSecret"
# 接口地址
API_URL="https://api.shuxuntech.com/v1/business/ocr"
# 图片base64
IMAGE=""
# 图片url
IMG_URL=""
# 1、当前 unix 时间毫秒值,服务端要求与服务器时间相差不能超过 5 分钟
TIMESTAMP=$(($(date +%s) * 1000))
# 2、签名:按顺序拼接 appKey + timestamp + appSecret 后做 sha256,得到小写十六进制字符串
# 没有 openssl 时可用: SIGN=$(printf '%s' "${APP_KEY}${TIMESTAMP}${APP_SECRET}" | sha256sum | awk '{print $1}')
SIGN=$(printf '%s' "${APP_KEY}${TIMESTAMP}${APP_SECRET}" | openssl dgst -sha256 | awk '{print $NF}')
# 3、业务参数放在请求体里(--data-urlencode 会自动对中文做 URL 编码)
# 4、发起 POST 请求,appKey、timestamp、sign 放在请求头
# 5、-w 参数在返回内容后打印 HTTP 状态码,便于查看结果
curl -sS -X POST "${API_URL}" \
-H "appKey: ${APP_KEY}" \
-H "timestamp: ${TIMESTAMP}" \
-H "sign: ${SIGN}" \
--data-urlencode "image=${IMAGE}" \
--data-urlencode "imgUrl=${IMG_URL}" \
-w "\nHTTP状态码=%{http_code}\n"
java
python
php
c#
nodejs
go
curl
产品详情
API文档
示例代码
产品价格







