在使用文档相关接口时,需要通过access_key,access_secret生成鉴权信息。access_key,access_secret在注册登录后,通过AccessKey管理界面进行获取。
sign = method +"\n" + headers.accept +"\n" + headers.datetime +"\n" + headers.signature-nonce + "\n" + apiUrl
signature = Base64( HMAC-SHA1( key : access_secret, message : UTF-8-Encoding-Of( sign ) ) )
headers.authorization = "ak"+ " " + access_key + ":" + signature
x// GET /api/documents?id=1const method = 'GET'const apiUrl = '/api/documents?id=1'sign = method + "\n"+ headers['accept'] + "\n"+ headers['datetime'] + "\n"+ headers['signature-nonce'] + "\n"+ apiUrlconst hmac_sha1 = createHmac('sha1', access_secret)const message = hmac.update(sign).digest('hex')const signature = Buffer.from(message, 'utf-8').toString('base64');headers['authorization'] = "ak"+ " " + access_key + ":" + authorization
xxxxxxxxxxString makeAuthorization() throws SignatureException, NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException {String sign = "";String accessKey = "tIRU1Rz9iAQ7zylF";String accessSecret = "QFoHCDsuq1XH";String method = "GET";String accept = "application/json";String apiUrl = "/api/documents?id=1";String datetime = "2022-09-01 06:23:00";int signatureOnce = 456789;sign = method + "\n"+ accept + "\n"+ datetime + "\n"+ signatureOnce + "\n"+ apiUrl;String base64 = Base64.encodeBase64String(hmacSHA1(sign, accessSecret));String authString = "ak " + accessKey + ":" + base64;return authString;}public byte[] hmacSHA1(String data, String key) throws java.security.SignatureException, NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException {SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), "HmacSHA1");Mac mac = Mac.getInstance("HmacSHA1");mac.init(signingKey);byte[] rawHmac = mac.doFinal(data.getBytes("UTF-8"));return bytesToHexStr(rawHmac).getBytes();}public static String bytesToHexStr(byte[] bytes) {StringBuilder hexStr = new StringBuilder();for (byte b : bytes) {String hex = Integer.toHexString(b & 0xFF);if (hex.length() == 1) {hex = '0' + hex;}hexStr.append(hex);}return hexStr.toString();}
通过生成的鉴权信息发起请求示例:
AccessKey:tIRU1Rz9iAQ7zylF AccessSecret:QFoHCDsuq1XH
xxxxxxxxxxcurl --location --request GET 'http://hostname/api/documents?id=1' \--header 'authorization: ak tIRU1Rz9iAQ7zylF:ODU2ZmQzMjZhMTUwYTI5YzE2M2NhYzdlZDlhYzdmODA0NTAxMGNmYw==' \--header 'datetime: 2022-09-01 06:23:00' \--header 'accept: application/json' \--header 'signature-nonce: 456789' \--data-raw ''
xMethod: POSTType: FORMDATAURL: {{host-port}}/api/documents
POST /api/documents?async=0
Query:
| Key | Value | Description |
|---|---|---|
| async | 0 | 异步解析, 0为同步1为异步 |
Form-data:
| Key | Value | Description |
|---|---|---|
| file | Book.pdf |
响应字段:
| 字段 | 描述 |
|---|---|
| status | 调用状态:1(成功),2(等待),3(处理中),-1(失败) |
| url | 源文件url,可通过调用查看文件接口查看 |
| result_url | 解析结果文件url,可通过调用查看文件接口查看 |
| result | 解析结果 |
x{"id": 31,"name": "Renaissance.pdf","status": 1,"url": " host.com/api/file/doc/1/1661930936-OXbhdWGt9H4a4ipN.pdf","config": {},"user_id": 1,"created_at": "2022-08-31 07:28:56","updated_at": "2022-08-31 07:28:57","result_url": " host.com/api/file/doc/1/1661930936-OXbhdWGt9H4a4ipN.pdf.result.json","result": {"tree": [{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 158.5861},"text": "Available online at www.sciencedirect.com","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": true,"fontSize": 16,"indent": 195.3701},"text": "ScienceDirect","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": -1,"indent": 0},"text": "oss.com/301b12a5-ecb9-4d39-a050-cc913f2d76d9/e8e4fbac-1d09-4a21-a077-d380ac239163.jpg?Expires=4815530936&OSSAccessKeyId=LTAI5t6Yn15eubMcEe86PdKo&Signature=7HprB%2FzMMmm5Uh20uY%2FeaLA8mmI%3D","type": "IMAGE","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 8,"indent": 160.2615},"text": "M aterials Today: Proceedings 2 (2 015 ) 3884 – 3888","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": -1,"indent": 0},"text": "oss.com/301b12a5-ecb9-4d39-a050-cc913f2d76d9/dc27c4f2-826a-4447-abe8-9d7fc6ad6c38.tiff?Expires=4815530937&OSSAccessKeyId=LTAI5t6Yn15eubMcEe86PdKo&Signature=Dfxnj0fFNzVQHvaYOk20D3riWAc%3D","type": "IMAGE","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 11,"indent": 43.0056},"text": "The Selected Papers of 10th International Conference on Physics of Advanced Materials, ICPAM-","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 11,"indent": 262.1422},"text": "10","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 16,"indent": 70.0337},"text": "Visible and invisible structures in Renaissance paintings","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 12,"indent": 165.7397},"text": "Gabriel Ciobanu1, Cristian Ungureanu2*","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 4,"indent": 149.6474},"text": "1Romanian Academy, ICS, Str. Dr. Codrescu, Nr. 2, Iasi, 700 481, Romania2“George Enescu” University of Arts, Str sararie nr.189, Iasi 70045, Romania","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 8,"indent": 40.6776},"text": "Abstract","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 8,"indent": 40.68634},"text": "In order to emphasize the links between science and art, we analyze the Renaissance painting of the 15th century known under thename of „The Creation of the World and the Expulsion from Paradise”. This composition displays not only the artistic qualities,but also a symbolic meaning of the image following the internal geometric structure used by the Italian master when painting thismasterpiece. The invisible structure is developed around three circles emphasizing the round halos of the Creator and of the Angel,as well as around the concentric circular universe depicted in the left half of the composition. A precise numerical ratio obtainedthrough the expansion of these three circles reveals both the significance of all the elements distinguished in this wonderful pieceof art.","type": "PARAGRAPH","stage": "unknown"}]}}
Status Code: 200
xxxxxxxxxxMethod: GETType:URL: /api/documents
GET /api/documents
x{"current_page": 1,"data": [{"id": 30,"name": "携程订单18765558286电子发票.pdf","status": 1,"url": "doc/1/1661846892-VYYgvTojTTfjhK25.pdf","config": {},"user_id": 1,"created_at": "2022-08-30 08:08:12","updated_at": "2022-08-30 08:08:13"},{"id": 29,"name": "invoice.pdf","status": 1,"url": "doc/1/1661846885-x6f5fMGfCRqXyMK5.pdf","config": {},"user_id": 1,"created_at": "2022-08-30 08:08:05","updated_at": "2022-08-30 08:08:06"},{"id": 28,"name": "P020211126385924331809.pdf","status": 1,"url": "doc/1/1661837361-J9cTtmIWPhDPv6RG.pdf","config": {},"user_id": 1,"created_at": "2022-08-30 05:29:21","updated_at": "2022-08-30 05:29:23"},{"id": 27,"name": "603933_20190913_2.pdf","status": 1,"url": "doc/1/1661754860-JNy2vof90zCYYSAN.pdf","config": {"mode": "invoice"},"user_id": 1,"created_at": "2022-08-29 06:34:20","updated_at": "2022-08-29 06:34:21"},{"id": 26,"name": "Renaissance.pdf","status": 1,"url": "doc/1/1661753488-mYyIZfGz3bcQes7U.pdf","config": {},"user_id": 1,"created_at": "2022-08-29 06:11:28","updated_at": "2022-08-29 06:11:29"}],"first_page_url": " /api/documents?current_page=1","from": 1,"last_page": 1,"last_page_url": " /api/documents?current_page=1","links": [{"url": null,"label": "« 上一页","active": false},{"url": " /api/documents?current_page=1","label": "1","active": true},{"url": null,"label": "下一页 »","active": false}],"next_page_url": null,"path": " /api/documents","per_page": 20,"prev_page_url": null,"to": 5,"total": 5}
Status Code: 200
xxxxxxxxxxMethod: GETType:URL: {{host-port}}/api/documents/{id}
GET /api/documents/29
响应字段:
x{"id": 29,"name": "invoice.pdf","status": 1,"url": " host.com/api/file/doc/1/1661846885-x6f5fMGfCRqXyMK5.pdf","config": {},"user_id": 1,"created_at": "2022-08-30 08:08:05","updated_at": "2022-08-30 08:08:06","result_url": " host.com/api/file/doc/1/1661846885-x6f5fMGfCRqXyMK5.pdf.result.json"}
Status Code: 200
xxxxxxxxxxMethod: GETType:URL: {{host-port}}/api/file/{url}
GET /api/file/doc/1/1661846885-x6f5fMGfCRqXyMK5.pdf.result.json
xxxxxxxxxx{"tree": [{"display": {"align": "center","bold": false,"fontSize": 21,"indent": 194.9999},"text": "江苏增值税电子普通发票","type": "TITLE","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 446.08505},"text": "发票代码 :032002200111","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 7,"indent": 291.3565},"text": "统一发票监国 制","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 446.08505},"text": "发票号码 :58859390","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 7,"indent": 287.962},"text": "国家税务总局","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 7,"indent": 285.0067},"text": "江","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 446.08505},"text": "开票日期 :2022年08月14日苏","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 7,"indent": 333.333},"text": "局","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 30.546051},"text": "机器编号 :499099743685","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 7,"indent": 303.6811},"text": "省税务","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 447.08405},"text": "校 验 码 :11343 30733 45409 02338","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 38.2292},"text": "购","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 58.7007},"text": "名 称 : 复旦大学","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 366.624},"text": "密","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 12,"indent": 386.2},"text": "03/<1><129***+>>555/849>7910","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 112.54499},"text": ":","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 38.2292},"text": "买","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 59.357704},"text": "纳税人识别号12100000425006117P","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 367.335},"text": "码","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 12,"indent": 386.2},"text": "08**54/-6>2033+5<>--+89<6*+9","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 59.2637},"text": "地 址、电 话: *58+38/886+3+-96-195/*97-527方","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 58.8667},"text": "开户行及账号 :","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 366.624},"text": "区 82+39>*68-01*526191*41<>5<45","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 52.577972},"text": "货物或应税劳务、服务名称 规格型号 单位 数 量 单 价 金 额 税率 税 额","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 8,"indent": 33.77},"text": "*文具*金得利 75mm 粘扣档案盒 加 TD075 个 2 7.96 15.93 13% 2.07厚文件盒A4塑料党建资料盒 财务凭","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 8,"indent": 33.77},"text": "证收纳盒 蓝色 TD075","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 78.40802},"text": "合 计","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 8,"indent": 448.56},"text": "¥ 15.93 ¥ 2.07","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 71.71202},"text": "价税合计 (大写) 壹拾捌元整","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 442.0052},"text": "(小写)","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 8,"indent": 557.31},"text": "¥ 18.00","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 58.68902},"text": "名 称 : 昆山京东尚信贸易有限公司","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 8,"indent": 382.66},"text": "订单号:250571765512","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 38.5352},"text": "销","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 59.346016},"text": "纳税人识别号:","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 366.41418},"text": "备","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 10,"indent": 118.63},"text": "9 13205830880018839","type": "PARAGRAPH","stage": "S0"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 38.661198},"text": "售","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 59.2637},"text": "地 址、电 话: 千灯镇圣祥东路25号2号 0512-39915704","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 38.5352},"text": "方","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 58.8667},"text": "开户行及账号 :","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 366.41418},"text": "注中国建设银行股份有限公司昆山市千灯支行 32201986438051511848","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 44.55},"text": "收款人: 王陆 复核:李思","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 9,"indent": 333.83704},"text": "开票人:汤丹丹 销售方: ( 章)","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 7,"indent": 336.0446},"text": "全","type": "PARAGRAPH","stage": "unknown"},{"display": {"align": "left","bold": false,"fontSize": 7,"indent": 52.9834},"text": "章","type": "PARAGRAPH","stage": "unknown"}]}
Status Code: 200
xxxxxxxxxxMethod: DELETEType: FORMDATAURL: {{host-port}}/api/documents/{id}
DELETE /api/documents/31
xxxxxxxxxx{"id": 31,"name": "Renaissance.pdf","status": 1,"url": "doc/1/1661930936-OXbhdWGt9H4a4ipN.pdf","config": {},"user_id": 1,"created_at": "2022-08-31 07:28:56","updated_at": "2022-08-31 07:28:57"}
Status Code: 200
| 字段 | 描述 |
|---|---|
| tree.display | 显示相关信息 |
| tree.display.align | 对齐方式 |
| tree.display.bold | 是否为粗体 |
| tree.display.fontSize | 字体大小 |
| tree.display.indent | 缩进 |
| tree.text | 文本内容 |
| tree.type | 元素类型 |
| tree.stage | 层级结构 |