除下载接口外,系统接口返回数据格式一般为 json
http 请求提交数据时,如未特殊说明,也使用 json 格式
接口均需要添加验证参数:_timestamp-时间戳 、_token-令牌
{
status: true,
errcode: 0,
msg: null,
data: {},
}
{
status: false,
errcode: 1,
msg: 'No File Found',
data: null,
}
使用python3运行Get_Token.py + 对应url
python3 Get_Token.py http://saas.pdflux.com/api/v1/saas/upload?user=####&force_updata=true
GET /api/v1/saas/usage?user=####
参数名 | 类型 | 说明 |
---|---|---|
user | string | 用户名,拼接在URL中,例:user=#### |
参数名 | 类型 | 说明 |
---|---|---|
rest | number | 已使用页数 |
total | number | 总页数 |
trial_start | string | 起始时间 |
trial_end | string | 截止时间 |
python3 Get_Token.py http://saas.pdflux.com/api/v1/saas/usage?user=pdflux
{
data: {
rest: 99952, // 已使用页数
total: 100001, // 总页数
trial_start: "2020-10-01 00:00:00", // 起始时间
trial_end: "2020-10-31 00:00:00", // 截止时间
},
errcode: 0,
msg: null,
status: true
}
POST /api/v1/saas/upload?force_update=true&file_type=##&user=####
参数名 | 类型 | 说明 |
---|---|---|
file | file | 待分析文档,必填 |
user | string | 用户名,拼接在URL中,例:user=#### |
file_type | string | 非必填,文档类型,指定文档类型后将使用对应的专用模型识别上传的文档,fs=财务报告,bs=银行流水 |
force_update | string | 非必填,强制文档重新识别,例如上传重复文件、旧文件时,PDFlux为了经济性默认会优先获取已有的旧结果,增加force_update=true后将会强制重新识别获取最新结果 |
参数名 | 类型 | 说明 |
---|---|---|
uuid | string | 文件 id,后续用于获取结果 |
checksum | string | 文件hash |
filename | string | 文件名 |
filepath | string | 文件路径 |
parsed | int | -1=解析异常、0=待解析、1=解析中、2=解析完毕、3=文档转换中 |
created_utc | int | 创建时间 |
updated_utc | int | 修改时间 |
python3 Get_Token.py http://saas.pdflux.com/api/v1/saas/upload?user=pdflux&force_updata=true&file_type=fs
POST http://saas.pdflux.com/api/v1/saas/upload?_timestamp=1590560297&_token=bf5bd348e4a414be0aa57899878bd66c&user=pdflux
{
status: true,
data: {
uuid: 'b75487ae-09d6-4948-bac5-7924d24bedbb',
checksum: 'dbc325d09eb6c8af234a57fe62ae6a20',
filename: '第二次公开募股.pdf',
filepath: '1672345948/f6f8e0b7df6188cd30b37004bbaa2b6d_1816579.pdf',
parsed: 1,
created_utc: 1508467057,
updated_utc: 1508467057,
},
}
GET /api/v1/saas/document/<uuid>?user=####
参数名 | 类型 | 说明 |
---|---|---|
created_utc | int | 创建时间 |
deleted | int | 删除,0代表未删除、1代表已删除 |
filename | string | 文件名 |
parsed | int | -1=解析异常、0=待解析、1=解析中、2=解析完毕、3=文档转换中 |
updated_utc | int | 修改时间 |
uuid | string | 文件 id,后续用于获取结果 |
python3 Get_Token.py http://saas.pdflux.com/api/v1/saas/document/<uuid>?user=pdflux
GET http://saas.pdflux.com/api/vl/saas/document/<uuid>?_timestamp=1590560297&_token=bf5bd348e4a414be0aa57899878bd66c&user=pdflux
{
data: {
created_utc: 1534819038,
deleted: 0,
filename: 'xxx.pdf',
id: 8,
parsed: 1,
updated_utc: 1534820149,
uuid: 'b5a95e7a-a4ed-11e8-8a4f-8c8590cb4e8f',
},
errcode: 0,
msg: null,
status: true,
}
GET /api/v1/saas/document/<uuid>/pdftables?user=####
参数名 | 类型 | 说明 |
---|---|---|
paragraphs | string | 段落元素块 |
tables | string | 表格元素块 |
images | string | 图片元素块 |
page_header | string | 页眉元素块 |
page_footer | string | 页脚元素块 |
*更多字段说明见结果示例及注释
python3 Get_Token.py http://saas.pdflux.com/api/v1/saas/document/<uuid>/pdftables?user=pdflux
GET http://saas.pdflux.com/api/v1/saas/document/<uuid>/pdftables?_timestamp=1590562575&_token=bc62219c497be230697368b87930eb33&user=pdflux
{
"document": [
{
"id": 2022,
"uuid": "2afdca4a-5c65-11eb-a1f8-00163e055917", // 文件uuid
"parsed": 2,
"filename": "中国广核电力股份有限公司主体与2019年度第一期中期票据信用评级报告(中诚信国际).pdf", // 文件名
"created_utc": 1611287515, // 创建时间
"updated_utc": 1611287688, // 修改事件
"exceptions": null // 报错信息
}
],
"pdf_page": [
{
"id": 10379,
"did": 2022,
"page": 0, // 页面序号、页码
"meta": {
"width": 595, // 页面宽度
"height": 842, // 页面高度
"page_type": null,
"page_prob": null,
"is_image": true // 是否是扫描件或图片
},
"created_utc": 1611287679,
"updated_utc": 1611287679
},
... // ...表示省略
],
"pdf_elements": [
{
"page": 1, // 页面序号、页码
"elements": [
{
"page": 1, // 页面序号、页码
"text": "中诚信国呩 CCXI-20182331D-01", // 文字内容
"index": 0,
"element_type": "page_headers" // 元素块类型:页眉
},
{
"page": 1,
"text": "中国广核电力股份有限公司2019年度第一期中期票据信用评级报告",
"index": 1,
"syllabus": 1, // 和目录的对应关系
"element_type": "paragraphs" // 元素块类型:段落
},
{
"unit": "", // 表格单位
"cells": { // 表格单元格
"0_0": { //
"value": "发行主体" // 单元格内的文字内容
},
"0_1": { // 单元格位置信息:第一个“0”代表的是行数,第二个”0“代表的是列数,”0_0"代表第一个单元格
"value": "中国卜核*力股份有限公司"
},
... // 表示省略
},
"title": "中国广核电力股份有限公司2019年度第一期中期票据信用评级报告",
"merged": [ // 单元格合并信息
[
[0,1],[0,2],[0,3],[0,4] // 表示这4个单元格合并
],
[
[1,1],[1,2],[1,3],[1,4] // 表示这4个单元格合并
],
... // 表示省略
],
"element_type": "tables", // 元素块类型:表格
"page": 1, // 页码
"index": 2 // 在页面中出现的顺序
},
{
"page": 1,
"text": "www.ccxi.com.cn 中国广核电力股份有限公司2019年度第一期中期票据信用评级报告",
"index": 3,
"element_type": "page_footers" // 元素块类型:页脚
}
]
},
{
"page": 2,
"elements": [
{
"data": "iVBORw0KGgoA......", // 图片内容,Base64格式
"page": 2, // 页码
"index": 0, // 在页面中出现的顺序
"element_type": "images" // 元素块类型:图片
},
{
"page": 2,
"text": "关 注",
"index": 1,
"element_type": "paragraphs",
},
...
]
},
...
],
"syllabus": { // 目录
"index": -1, // 目录根节点
"children": [ // 子节点
{
"page": 1,
"etype": "paragraphs",
"index": 1, // 目录序号
"level": 1, // 目录层级
"range": [ // 当前目录包含的元素块
1,10
],
"title": "中国广核电力股份有限公司2019年度第一期中期票据信用评级报告", // 目录标题
"parent": -1, // 父节点
"element": 1, // 目录与元素块的对应关系
"children": [ // 子节点
{
"page": 2,
"etype": "paragraphs",
"index": 2,
"level": 2,
"range": [
5,10
],
"title": "关 注",
"parent": 1,
"element": 5,
"children": []
}
]
},
{
"page": 3,
"etype": "paragraphs",
"index": 3,
"level": 1,
"range": [
10,20
],
"title": "声明",
"parent": -1,
"element": 10,
"children": []
},
...
]
}
}
GET /api/v1/saas/document/<uuid>/excel?user=####
参数名 | 类型 | 说明 |
---|---|---|
uuid | string | 文件 uuid |
返回内容为 excel 文件
python3 Get_Token.py http://saas.pdflux.com/api/v1/saas/document/<uuid>/excel?user=pdflux
GET http://saas.pdflux.com/api/v1/saas/document/<uuid>/excel?_timestamp=1590562650&_token=1a014dbd2c719cea3ed04f249b50e39e&user=pdflux
GET /api/v1/saas/document/<uuid>/html?user=####
参数名 | 类型 | 说明 |
---|---|---|
uuid | string | 文件 uuid |
返回内容为 html 文件
python3 Get_Token.py http://saas.pdflux.com/api/v1/saas/document/<uuid>/html?user=pdflux
GET http://saas.pdflux.com/api/v1/saas/document/<uuid>/html?_timestamp=1590562650&_token=1a014dbd2c719cea3ed04f249b50e39e&user=pdflux
目前报错信息分为三类:
解析错误(Parsing Error)
模型预测失败(Model Error)
OCR 调用错误(OCR Error)
{
data: {
created_utc: 1600080922,
deleted: 0,
filename: "1.pdf",
id: 1977,
parsed: -1,
updated_utc: 1600080953,
uuid: "c9689c8a-f678-11ea-a10a-00163e055917",
exceptions: {
error_type: "model_error",
description: "grpc predicts failure!(pdflux saas exception test!)"
}
},
errcode: 0,
msg: null,
status: true
}