接入指引
请先查看接入指引了解具体接入方式,再参考此文档完成接入。
请求API
名称 | 内容 |
---|
请求方式 | POST |
Content-Type | application/x-www-form-urlencoded |
图片要求 | 1. 文件格式:pdf/doc/docx。 2. 图片文件大小:最大 10 MB。 |
输入参数
Query参数:
参数 | 可选/必选 | 类型 | 说明 |
---|
Action | 必选 | String | 接口名,取值:OCRPdf |
Version | 必选 | String | 版本号,取值:2021-08-23 |
Body参数:
参数 | 可选/必选 | 类型 | 说明 |
---|
image_base64 | 必选 | String | 文件base64编码 |
file_type | 可选 | String | 文件类型:"pdf"/"doc", 默认为"pdf" |
data 字段说明
字段 | 类型 | 说明 | 备注 |
---|
page_infos | Array of page_info | 页面信息 | 字段说明见下方 |
page_info 字段说明
字段 | 类型 | 说明 | 备注 |
---|
poly | Array of Points | 行矩形框信息(可能有倾斜矩形) | 四个点的坐标,[左上, 右上, 右下, 左下] |
text | Array of String | 识别结果 | 文本识别结果 |
Point信息
字段 | 类型 | 说明 | 备注 |
---|
x | float | 坐标点横坐标占尺寸的百分比 | |
y | float | 坐标点纵坐标占尺寸的百分比 | |
错误码
HttpCode | 错误码 | 错误消息 | 描述 |
---|
200 | 10000 | 无 | 请求成功 |
401 | 50205 | "Image Size Exceeds Maximum Limit: please compress the image" | 文件大小超过上限 |
400 | 50207 | "Image Decode Error: image format unsupported" | 文件解码错误,文件内容为空或格式错误 |
401 | 50400 | "Access denied due to invalid authentication information" | 鉴权失败 |
404 | 50402 | "Invalid Request URL" | 无效的请求路径 |
500 | 50500 | "Internal Error: please contact with bytedance engineering team" | 内部错误,需要联系开发人员 |
注: 更多通用反馈字段通用返回值和状态码
返回值示例
主页面图片返回值示例
{
"code":10000,
"data":{
"page_infos":[
{
"poly": [
[0.408198, 0.105675],
[0.589619, 0.105675],
[0.589619, 0.127048],
[0.408198, 0.127048]
]
"text": [
"咨询服务合同"
]
}
]
},
"message":"Success",
"request_id":"021629427766315fdbddc01010500400000000000000068da22fd",
"time_elapsed":"5.330714543s"
}