文档解析接口用户手册
接口概述
/v1/document/parse 接口用于解析各种格式的文档,将文档内容转换为结构化的数据格式。该接口支持同步和异步两种处理模式,能够解析文档中的文本、图片、表格、标题等各种元素,并保持文档的层级结构。
当前只支持 doc 文档。
核心特性
- 多格式支持:支持 PDF、Word、Excel、PowerPoint 等多种文档格式(暂时只支持
doc文档) - 结构化解析:保持文档的层级结构和元素关系
- 智能识别:自动识别标题、段落、表格、图片等元素类型
- 异步处理:支持异步模式处理大文档,提供回调通知
- 同步模式:支持阻塞模式,直接返回解析结果
请求参数
HTTP 方法
POST /v1/document/parse
请求头
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
请求体参数
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
file | SourceFile | 是 | 文档文件信息 |
user | string | 否 | 用户标识 |
model | string | 是 | 解析模型名称 |
type | string | 否 | 处理类型:task(异步,默认)或 blocking(同步) |
callbackUrl | string | 否 | 异步模式下的回调地址 |
maxTimeoutMillis | integer | 否 | 同步模式下的最大等待时间(毫秒,最小30000) |
SourceFile 对象
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
id | string | 是 | 文件ID(通过文件上传接口获得) |
name | string | 是 | 文件名 |
type | string | 否 | 文件类型(如:pdf、docx) |
mime_type | string | 否 | MIME类型(如:application/pdf) |
请求示例
异步模式请求
{
"file": {
"id": "file_abc123",
"name": "document.pdf",
"type": "pdf",
"mime_type": "application/pdf"
},
"user": "user123",
"type": "task",
"callbackUrl": "https://your-domain.com/callback"
}
同步模式请求
{
"file": {
"id": "file_abc123",
"name": "document.pdf",
"type": "pdf",
"mime_type": "application/pdf"
},
"user": "user123",
"type": "blocking",
"maxTimeoutMillis": 60000
}