国内通用票据v2接口识别
curl --request POST \
--url https://api.textin.com/ai/service/v1/bill_recognize_v2 \
--header 'Content-Type: application/octet-stream' \
--header 'x-ti-app-id: <api-key>' \
--header 'x-ti-secret-code: <api-key>' \
--data successimport requests
url = "https://api.textin.com/ai/service/v1/bill_recognize_v2"
payload = "success"
headers = {
"x-ti-app-id": "<api-key>",
"x-ti-secret-code": "<api-key>",
"Content-Type": "application/octet-stream"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-ti-app-id': '<api-key>',
'x-ti-secret-code': '<api-key>',
'Content-Type': 'application/octet-stream'
},
body: 'success'
};
fetch('https://api.textin.com/ai/service/v1/bill_recognize_v2', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.textin.com/ai/service/v1/bill_recognize_v2",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "success",
CURLOPT_HTTPHEADER => [
"Content-Type: application/octet-stream",
"x-ti-app-id: <api-key>",
"x-ti-secret-code: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.textin.com/ai/service/v1/bill_recognize_v2"
payload := strings.NewReader("success")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-ti-app-id", "<api-key>")
req.Header.Add("x-ti-secret-code", "<api-key>")
req.Header.Add("Content-Type", "application/octet-stream")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.textin.com/ai/service/v1/bill_recognize_v2")
.header("x-ti-app-id", "<api-key>")
.header("x-ti-secret-code", "<api-key>")
.header("Content-Type", "application/octet-stream")
.body("success")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.textin.com/ai/service/v1/bill_recognize_v2")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-ti-app-id"] = '<api-key>'
request["x-ti-secret-code"] = '<api-key>'
request["Content-Type"] = 'application/octet-stream'
request.body = "success"
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "success",
"pageNum": 1,
"pages": [
{
"result": {
"object_list": [
{
"type": "other",
"type_description": "增值税普通发票",
"image_angle": 0,
"rotated_image_width": 1000,
"rotated_image_height": 3000,
"kind": "other",
"kind_description": "交通",
"position": [
100,
100,
200,
100,
200,
200,
100,
200
],
"stamp_list": [
[
{
"key": "stamp_type",
"value": "全国统一发票监制章",
"description": "印章类型",
"position": [
100,
100,
200,
100,
200,
200,
100,
200
]
}
]
],
"qr_code_list": [
[
{
"key": "qr_code_info",
"value": "01,61,,24118999111000010898,770.00,20240412,,0134",
"description": "二维码内容",
"position": [
100,
100,
200,
100,
200,
200,
100,
200
]
}
]
],
"item_list": [
{
"key": "title",
"value": "True",
"position": [
100,
100,
200,
100,
200,
200,
100,
200
],
"description": "标题"
}
]
}
]
},
"page_number": 0,
"duration": 7700,
"ppi": 0
}
]
}票据识别
通用票据识别
POST
/
ai
/
service
/
v1
/
bill_recognize_v2
国内通用票据v2接口识别
curl --request POST \
--url https://api.textin.com/ai/service/v1/bill_recognize_v2 \
--header 'Content-Type: application/octet-stream' \
--header 'x-ti-app-id: <api-key>' \
--header 'x-ti-secret-code: <api-key>' \
--data successimport requests
url = "https://api.textin.com/ai/service/v1/bill_recognize_v2"
payload = "success"
headers = {
"x-ti-app-id": "<api-key>",
"x-ti-secret-code": "<api-key>",
"Content-Type": "application/octet-stream"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-ti-app-id': '<api-key>',
'x-ti-secret-code': '<api-key>',
'Content-Type': 'application/octet-stream'
},
body: 'success'
};
fetch('https://api.textin.com/ai/service/v1/bill_recognize_v2', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.textin.com/ai/service/v1/bill_recognize_v2",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "success",
CURLOPT_HTTPHEADER => [
"Content-Type: application/octet-stream",
"x-ti-app-id: <api-key>",
"x-ti-secret-code: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.textin.com/ai/service/v1/bill_recognize_v2"
payload := strings.NewReader("success")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-ti-app-id", "<api-key>")
req.Header.Add("x-ti-secret-code", "<api-key>")
req.Header.Add("Content-Type", "application/octet-stream")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.textin.com/ai/service/v1/bill_recognize_v2")
.header("x-ti-app-id", "<api-key>")
.header("x-ti-secret-code", "<api-key>")
.header("Content-Type", "application/octet-stream")
.body("success")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.textin.com/ai/service/v1/bill_recognize_v2")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-ti-app-id"] = '<api-key>'
request["x-ti-secret-code"] = '<api-key>'
request["Content-Type"] = 'application/octet-stream'
request.body = "success"
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "success",
"pageNum": 1,
"pages": [
{
"result": {
"object_list": [
{
"type": "other",
"type_description": "增值税普通发票",
"image_angle": 0,
"rotated_image_width": 1000,
"rotated_image_height": 3000,
"kind": "other",
"kind_description": "交通",
"position": [
100,
100,
200,
100,
200,
200,
100,
200
],
"stamp_list": [
[
{
"key": "stamp_type",
"value": "全国统一发票监制章",
"description": "印章类型",
"position": [
100,
100,
200,
100,
200,
200,
100,
200
]
}
]
],
"qr_code_list": [
[
{
"key": "qr_code_info",
"value": "01,61,,24118999111000010898,770.00,20240412,,0134",
"description": "二维码内容",
"position": [
100,
100,
200,
100,
200,
200,
100,
200
]
}
]
],
"item_list": [
{
"key": "title",
"value": "True",
"position": [
100,
100,
200,
100,
200,
200,
100,
200
],
"description": "标题"
}
]
}
]
},
"page_number": 0,
"duration": 7700,
"ppi": 0
}
]
}Authorizations
Query Parameters
调整各字段的返回坐标逻辑,1代表坐标以原图为基准,0代表坐标以票据切图为基准,默认为0
Available options:
0, 1 指定多页样本中需要识别的样本,可以使用"1,3,2"形式来逐页选择,或"2-4"形式来连续选择,返回结果会重新排序以遵照源文件顺序,默认为空,识别所有页面
Example:
"3-5,1"
选择是否需要输出各票据图片,1为输出各票据切片base64编码,0为不输出各票据图片,默认为0
Available options:
0, 1 选择是否返回关键字段切图图片,1为输出字段图片,0为不输出字段图片,默认为0
Available options:
0, 1 支持将多页全电票的结果合并为一页,1为合并,0为不合并,默认为0 当且仅当一份多页样本的每一页都是全电票,且每张发票的发票号码都一致时才可合并。
Available options:
0, 1 返回pdf解码ppi
Available options:
0, 1 Body
application/octet-stream
支持以下两种请求格式
-
Content-Type: application/octet-stream 要上传的图片,目前支持jpg、png、bmp、pdf、tiff、ofd、xml、单帧gif等大部分格式,pdf和ofd文件支持多页请注意,请求体的数据格式为本地文件的二进制流,非 FormData 或其他格式。文件大小不超过 50M,图像宽高须介于 20 和 10000(像素)之间。
-
Content-Type: text/plain 请求体的数据格式为文本,内容为在线文件的URL链接(支持http以及https协议)。在线文件大小不超过 50M,图像宽高须介于 20 和 10000(像素)之间。
The body is of type file.
Response
200 - application/json
错误码
- 200: success
- 40101: x-ti-app-id 或 x-ti-secret-code 为空
- 40102: x-ti-app-id 或 x-ti-secret-code 无效,验证失败
- 40003: 余额不足,请充值后再使用
- 40004: 参数错误,请查看技术文档,检查传参
- 40007: 机器人不存在或未发布
- 40008: 机器人未开通,请至市场开通后重试
- 40301: 文件类型不支持,接口会返回实际检测到的文件类型,如“当前文件类型为.gif”
- 40302: 上传文件大小不符,文件大小不超过 50M
- 40303: 文件类型不支持
- 40304: 图片尺寸不符,图像宽高须介于 20 和 10000(像素)之间
- 40305: 识别文件未上传
- 40306: QPS超过限制,收到此状态码时请勿重试,持续请求可能触发IP流控,如需扩容请联系商务
- 40400: 无效的请求链接,请检查链接是否正确
- 30203: 基础服务故障,请稍后重试
- 500: 服务器内部错误
Available options:
200, 40101, 40102, 40003, 40004, 40007, 40008, 40301, 40302, 40303, 40304, 40305, 40306, 40400, 30203, 500 Example:
200
成功或错误信息
Example:
"success"
总页数
Example:
1
样本每页的识别结果
Show child attributes
Show child attributes
Was this page helpful?

