跳转到主要内容
POST
/
api
/
v1
/
xparse
/
parse
/
sync
文档解析
curl --request POST \
  --url https://api.textin.com/api/v1/xparse/parse/sync \
  --header 'Content-Type: multipart/form-data' \
  --header 'x-ti-app-id: <api-key>' \
  --header 'x-ti-secret-code: <api-key>' \
  --form file='@example-file' \
  --form 'file_url=<string>' \
  --form 'config={
  "document": {
    "password": "example-pdf-password"
  },
  "capabilities": {
    "include_hierarchy": true,
    "include_inline_objects": true,
    "include_char_details": true,
    "include_image_data": true,
    "include_table_structure": true,
    "pages": true,
    "title_tree": true,
    "table_view": "html"
  },
  "scope": {
    "page_range": "1-2"
  },
  "config": {
    "force_engine": "textin",
    "engine_params": {
      "formula_level": 0,
      "image_output_type": "url"
    }
  }
}'
{
  "code": 200,
  "message": "success",
  "data": {
    "schema_version": "1.3.0",
    "file_id": "doc_7f3a2b",
    "job_id": "job_x9k2m",
    "success_count": 2,
    "metadata": {
      "filename": "quarterly_report.pdf",
      "filetype": "application/pdf",
      "page_count": 2,
      "data_source": {
        "record_locator": {
          "protocol": "file",
          "remote_file_path": "/projects/demo/quarterly_report.pdf"
        },
        "url": "file:///projects/demo/quarterly_report.pdf"
      }
    },
    "markdown": "# 检验结果\n\n<table>\n  <thead>\n    <tr><th>项目</th><th>公式项</th><th>参考范围</th></tr>\n  </thead>\n  <tbody>\n    <tr><td>空腹血糖</td><td>x^2+1</td><td>3.9-6.1</td></tr>\n  </tbody>\n</table>\n\n乙方签字:李四\n\n设违约金函数f(x)=x^2+1。\n该违约金函数适用于逾期超过30日的场景。",
    "elements": [
      {
        "element_id": "el_001",
        "type": "Title",
        "text": "检验结果",
        "page_number": 1,
        "coordinates": [
          0.1,
          0.12,
          0.32,
          0.12,
          0.32,
          0.16,
          0.1,
          0.16
        ],
        "metadata": {
          "category_depth": 0,
          "children_ids": [
            "el_002",
            "el_003",
            "el_004",
            "el_005"
          ],
          "is_continuation": false,
          "data_source": {
            "record_locator": {
              "protocol": "file",
              "remote_file_path": "/projects/demo/quarterly_report.pdf"
            },
            "url": "file:///projects/demo/quarterly_report.pdf"
          }
        }
      },
      {
        "element_id": "el_002",
        "type": "Table",
        "text": "项目 公式项 参考范围\n空腹血糖 x^2+1 3.9-6.1",
        "page_number": 1,
        "coordinates": [
          0.1,
          0.2,
          0.82,
          0.2,
          0.82,
          0.36,
          0.1,
          0.36
        ],
        "metadata": {
          "parent_id": "el_001",
          "ref_element_id": "el_001",
          "is_continuation": false,
          "data_source": {
            "record_locator": {
              "protocol": "file",
              "remote_file_path": "/projects/demo/quarterly_report.pdf"
            },
            "url": "file:///projects/demo/quarterly_report.pdf"
          }
        },
        "table_structure": {
          "rows": 2,
          "cols": 3,
          "cells": [
            {
              "cell_id": "tbl_001_r1_c1",
              "row": 1,
              "col": 1,
              "row_span": 1,
              "col_span": 1,
              "content_type": "text",
              "text": "项目",
              "coordinates": [
                0.1,
                0.2,
                0.26,
                0.2,
                0.26,
                0.24,
                0.1,
                0.24
              ]
            },
            {
              "cell_id": "tbl_001_r2_c2",
              "row": 2,
              "col": 2,
              "row_span": 1,
              "col_span": 1,
              "content_type": "formula",
              "text": "x^2+1",
              "coordinates": [
                0.33,
                0.24,
                0.52,
                0.24,
                0.52,
                0.28,
                0.33,
                0.28
              ],
              "char_details": [
                {
                  "index": 0,
                  "text": "x",
                  "coordinates": [
                    0.33,
                    0.24,
                    0.34,
                    0.24,
                    0.34,
                    0.28,
                    0.33,
                    0.28
                  ],
                  "recognition": {
                    "confidence": 0.998,
                    "candidates": [
                      {
                        "text": "8",
                        "confidence": 0.998
                      }
                    ]
                  }
                }
              ]
            }
          ]
        }
      },
      {
        "element_id": "el_003",
        "type": "Image",
        "sub_type": "diagram",
        "text": "",
        "page_number": 1,
        "coordinates": [
          0.56,
          0.2,
          0.8,
          0.2,
          0.8,
          0.34,
          0.56,
          0.34
        ],
        "image_data": {
          "image_url": "https://example.com/fig-1.png",
          "mime_type": "image/png",
          "ocr_text": "签署流程",
          "description": "一张展示签署流程的流程图"
        },
        "metadata": {
          "parent_id": "el_001",
          "width": 640,
          "height": 360,
          "data_source": {
            "record_locator": {
              "protocol": "file",
              "remote_file_path": "/projects/demo/quarterly_report.pdf"
            },
            "url": "file:///projects/demo/quarterly_report.pdf"
          }
        }
      },
      {
        "element_id": "el_004",
        "type": "NarrativeText",
        "text": "乙方签字:李四",
        "page_number": 1,
        "coordinates": [
          0.1,
          0.4,
          0.3,
          0.4,
          0.3,
          0.46,
          0.1,
          0.46
        ],
        "metadata": {
          "parent_id": "el_001",
          "has_inline_objects": true,
          "inline_object_types": [
            "handwriting"
          ],
          "is_continuation": false,
          "data_source": {
            "record_locator": {
              "protocol": "file",
              "remote_file_path": "/projects/demo/quarterly_report.pdf"
            },
            "url": "file:///projects/demo/quarterly_report.pdf"
          }
        },
        "objects": [
          {
            "object_id": "obj_001",
            "type": "handwriting",
            "text": "李四",
            "text_range": [
              5,
              7
            ],
            "coordinates": [
              0.18,
              0.4,
              0.26,
              0.4,
              0.26,
              0.46,
              0.18,
              0.46
            ],
            "metadata": {}
          }
        ],
        "char_details": [
          {
            "index": 0,
            "text": "乙",
            "coordinates": [
              0.1,
              0.4,
              0.11,
              0.4,
              0.11,
              0.46,
              0.1,
              0.46
            ],
            "recognition": {
              "confidence": 0.997,
              "candidates": [
                {
                  "text": "乙",
                  "confidence": 0.997
                }
              ]
            }
          }
        ]
      },
      {
        "element_id": "el_005",
        "type": "NarrativeText",
        "text": "设违约金函数f(x)=x^2+1。",
        "page_number": 1,
        "coordinates": [
          0.1,
          0.48,
          0.36,
          0.48,
          0.36,
          0.54,
          0.1,
          0.54
        ],
        "metadata": {
          "parent_id": "el_001",
          "is_continuation": false,
          "has_inline_objects": true,
          "inline_object_types": [
            "formula"
          ],
          "data_source": {
            "record_locator": {
              "protocol": "file",
              "remote_file_path": "/projects/demo/quarterly_report.pdf"
            },
            "url": "file:///projects/demo/quarterly_report.pdf"
          }
        },
        "objects": [
          {
            "object_id": "obj_002",
            "type": "formula",
            "text": "x^2+1",
            "text_range": [
              11,
              16
            ],
            "coordinates": [
              0.22,
              0.48,
              0.3,
              0.48,
              0.3,
              0.54,
              0.22,
              0.54
            ],
            "metadata": {
              "display_mode": "inline"
            }
          }
        ],
        "char_details": [
          {
            "index": 0,
            "text": "设",
            "coordinates": [
              0.1,
              0.48,
              0.11,
              0.48,
              0.11,
              0.54,
              0.1,
              0.54
            ],
            "recognition": {
              "confidence": 0.999,
              "candidates": [
                {
                  "text": "设",
                  "confidence": 0.999
                }
              ]
            }
          }
        ]
      },
      {
        "element_id": "el_006",
        "type": "NarrativeText",
        "text": "该违约金函数适用于逾期超过30日的场景。",
        "page_number": 2,
        "coordinates": [
          0.1,
          0.1,
          0.44,
          0.1,
          0.44,
          0.16,
          0.1,
          0.16
        ],
        "metadata": {
          "is_continuation": true,
          "continuation_of": "el_005",
          "data_source": {
            "record_locator": {
              "protocol": "file",
              "remote_file_path": "/projects/demo/quarterly_report.pdf"
            },
            "url": "file:///projects/demo/quarterly_report.pdf"
          }
        }
      }
    ],
    "title_tree": [
      {
        "element_id": "el_001",
        "title": "检验结果",
        "level": 1,
        "page_number": 1,
        "children": []
      }
    ],
    "pages": [
      {
        "page_number": 1,
        "page_width": 1576,
        "page_height": 1683,
        "page_image_url": "https://example.com/page-1.jpg",
        "element_ids": [
          "el_001",
          "el_002",
          "el_003",
          "el_004",
          "el_005"
        ],
        "dpi": 144,
        "angle": 0,
        "status": "Success"
      },
      {
        "page_number": 2,
        "page_width": 1576,
        "page_height": 1683,
        "page_image_url": "https://example.com/page-2.jpg",
        "element_ids": [
          "el_006"
        ],
        "dpi": 144,
        "angle": 0,
        "status": "Success"
      }
    ],
    "summary": {
      "duration_ms": 812
    }
  }
}

授权

x-ti-app-id
string
header
必填

登录Textin后前往 "工作台-账号设置-开发者信息" 查看 x-ti-app-id

x-ti-secret-code
string
header
必填

登录Textin后前往 "工作台-账号设置-开发者信息" 查看 x-ti-secret-code

请求体

multipart/form-data
file
file

上传文档文件,与 file_url 二选一

file_url
string

文档 URL,与 file 二选一

config
object

解析参数配置

示例:
{
"document": { "password": "example-pdf-password" },
"capabilities": {
"include_hierarchy": true,
"include_inline_objects": true,
"include_char_details": true,
"include_image_data": true,
"include_table_structure": true,
"pages": true,
"title_tree": true,
"table_view": "html"
},
"scope": { "page_range": "1-2" },
"config": {
"force_engine": "textin",
"engine_params": {
"formula_level": 0,
"image_output_type": "url"
}
}
}

响应

解析结果

code
enum<integer>
必填

状态码

  • 200: 成功
  • 40101: x-ti-app-id 或 x-ti-secret-code 为空
  • 40102: x-ti-app-id 或 x-ti-secret-code 无效,验证失败
  • 40103: 客户端IP不在白名单
  • 40003: 余额不足,请充值后再使用
  • 40004: 参数错误,请查看技术文档,检查传参
  • 40007: 机器人不存在或未发布
  • 40008: 机器人未开通,请至市场开通后重试
  • 40301: 图片类型不支持
  • 40302: 上传文件大小不符,文件大小不超过 500M
  • 40303: 文件类型不支持
  • 40304: 图片尺寸不符
  • 40305: 识别文件未上传
  • 40422: 文件损坏
  • 40423: PDF密码错误
  • 40424: 页数设置超出文件范围
  • 40425: 文件格式不支持
  • 40427: DPI参数不在支持列表中
  • 40428: word和ppt转pdf失败或者超时
  • 40429: 不支持的引擎
  • 50207: 部分页面解析失败
  • 40400: 无效的请求链接
  • 30203: 基础服务故障,请稍后重试
  • 500: 服务器内部错误
可用选项:
200,
40101,
40102,
40103,
40003,
40004,
40007,
40008,
40301,
40302,
40303,
40304,
40305,
40422,
40423,
40424,
40425,
40427,
40428,
40429,
50207,
40400,
30203,
500
示例:

200

message
string
必填

状态信息

示例:

"success"

location
object

错误定位信息,仅在解析错误时返回

data
object