用户认证
UniParser-API 使用请求头 X-API-Key 进行身份认证。可在 UniParser 主页通过玻尔登录一键授权获取 API-Key(首次登录自动发放试用额度),或在已有 API-Key 时直接填入使用;如需更高额度、更高权限或长期账号,请联系我们开通。
解析成功后收费,付款确认后开放结果。价格、待付款响应及恢复方式见下文“成功后收费与待付款”。
# 每个新任务生成一次 UUID;保留此变量供后续查询使用(需要 Python 3)。
uniparser_token="$(python3 -c 'import uuid; print(uuid.uuid4().hex)')"
curl -X POST "https://uniparser.dp.tech/trigger-file-async" \
-H "X-API-Key: your_api_key" \
-F "token=${uniparser_token}" \
-F "file=@example.pdf" \
-F "sync=true"
推荐将密钥放在环境变量中,例如 UNIPARSER_API_KEY,避免写入代码仓库。
| 接口 |
请求格式 |
说明 |
/trigger-file-async |
multipart/form-data |
上传 PDF 文件,文件字段为 file,其他参数也通过表单字段传入 |
/trigger-snip-async / /trigger-url-async |
JSON body |
图片片段或 URL 解析请求 |
/trigger-item-async |
application/x-www-form-urlencoded |
单元素解析,img 为 Base64 字符串;详见接入示例 |
/get-result / /get-formatted / /get-third-party-output |
JSON body(POST) |
查询状态或获取对应格式的结果,沿用原 token |
注意:token 是解析任务的唯一索引。单元素接口可省略 token 并由服务端生成;为便于超时后查询,建议主动生成并保存。其他 trigger 接口请按对应接入示例提供 token。使用 curl 或 Python 直接调用时,推荐为每个新任务生成 UUID;UniParser-Tools 的文档解析方法会自动生成 token。
重复提交提醒:每个新任务生成新的 UUID,查询结果沿用提交时的 token;同一 token 的重复提交可能返回 Token is duplicated,客户端超时后请先查询原任务,避免盲目重提或换 token 重跑。
sync 控制任务提交后的等待方式:sync=false 是默认异步模式,提交后立即返回任务状态和 token,需要稍后用同一 token 获取结果;sync=true 会在提交请求中等待解析完成或超时,适合示例、调试和小文件。大文件或批处理建议使用异步模式,并根据任务大小合理设置 timeout(默认 1800 秒)。
任务状态与进度
HTTP 状态表示请求是否被接受,status 表示任务状态,billing_status 表示计费阶段;三者不能互相替代。undefined 是已有的任务状态值,成功后收费流程增加了计费阶段和等待提示。
status |
含义与处理 |
undefined |
接收、准备任务,或尚无明确解析进度;保留 token 继续查询 |
waiting |
等待初始化、解析或付款确认;结合计费字段查看原因 |
processing |
正在解析;有进度时展示进度,继续查询 |
success |
任务成功,可获取结果;启用成功后收费时已确认付款 |
error |
当前任务失败;检查错误说明和错误码,不要无限轮询 |
例如,以下响应表示仍在等待,不是解析失败,也不表示余额不足或已经扣款:
{
"status": "undefined",
"description": "等待解析或付款完成",
"billing_status": "awaiting_parse",
"message": null,
"proc_page": null,
"total_page": null
}
awaiting_parse 表示已保存报价、等待解析成功后收款;解析期间也可能保持此值。created / preordering / paying 表示收款流程中,payment_unknown 表示付款结果待确认,paid 表示付款已确认。declined 不一定是余额不足,也可能是解析失败或结果过期,应结合 status、billing_code 和说明判断。
proc_page、total_page 缺失或为 null 表示暂无进度,不代表 0 页或失败;仅在数值有效且总页数大于 0 时计算百分比。100% 也不代表结果已开放。
payment_pending=true 表示付款尚未确认;该字段可能缺失,不能据此认定已付款。message 也可能为空。
description / message 是展示文案,可能调整;不要匹配中文文案判断状态。客户端应容忍新增字段。
- 使用原账号和 token 查询;仅在
success 时读取结果,error 时处理失败。遇到未知状态保留 token 并记录响应,不自动重提;等待过久请携带 token 联系支持。
明确拒付后,充值或仅等待 webhook 不会自动重试付款;请用原账号和 token 调用 POST /get-result、POST /get-formatted 或 POST /get-third-party-output 触发恢复。
上传超限兼容性变更: 现在返回 HTTP 413(此前为 400),描述文案也已变化。请按 error_code="FILE_SIZE_EXCEEDED" 判断,不要匹配旧状态码或固定描述。
解析配置 SemanticType
提交解析任务时,可以分别控制以下语义元素:
阶段提示:SemanticType 与 ParseMode / ParseModeTextual 属于提交阶段,用于决定解析哪些内容以及解析质量;不要在 /get-formatted 或 get_formatted 中使用它们。
| 参数 |
含义 |
可用模式 |
textual |
普通文本、标题、脚注等 |
0 / 1 / 2 / 3 / -1 / -3 |
equation |
独立数学公式 |
0 / 1 / 2 / -1 / -3 |
table |
表格 |
0 / 1 / 2 / -1 / -3 |
chart |
图表 |
0 / 1 / -1 / -3 |
figure |
图片、插图、照片 |
0 / 1 / -1 / -3 |
expression |
化学反应式 |
0 / 1 / -1 / -3 |
molecule |
化学分子结构 |
0 / 1 / -1 / -3 |
取值说明:0 表示禁用,1 表示快速解析,2 表示高质量解析,-1 表示返回原始图像 Base64,-3 表示将裁剪图片上传至 TOS 并返回下载链接(不进行该类别的 OCR)。textual 还支持 3,用于从数字原生 PDF 中直接抽取文字。
| 枚举名 |
对应数值 |
ParseMode.DumpHosting / ParseModeTextual.DumpHosting |
-3 |
ParseMode.DumpBase64 / ParseModeTextual.DumpBase64 |
-1 |
ParseMode.OCRFast / ParseModeTextual.OCRFast |
1 |
ParseMode.OCRHighQuality / ParseModeTextual.OCRHighQuality |
2 |
ParseModeTextual.DigitalExported |
3(仅 textual) |
注意:chart、expression、molecule 目前无高质量模式。
图片存储到 TOS(-3)
在提交请求时设置需要保留图片的类别,例如 figure=-3;上述所有语义类别均支持此模式。成功后,结果块的 source 为图片的 HTTP(S) GET 下载链接,Markdown/HTML 输出使用该链接。
链接默认从签名时起有效 7 天,具体有效期以服务提供的链接为准。再次读取结果不会自动续签,请在有效期内下载保存图片,并保持签名链接完整,不要修改域名或查询参数。
图片上传或生成下载链接失败时,该块按 DumpBase64=-1 返回原始图片 Base64,其他图片继续处理。dict_cfg 保留请求模式 -3,因此同一任务的 source 可能同时包含 URL 和 Base64。直接消费结果时应逐块区分;Markdown/HTML 会自动将回退图片转为 data URI。
表格模式:fast 与 hq
table=1(fast)返回的是“结构模板 + 单元格文本”的组合数据,通常需要结合 structure、placeholders 和 contents 还原表格:structure 描述表格骨架,placeholders 标记单元格占位,contents 提供对应的单元格文本。
table=2(hq)的 structure 中通常已经直接包含完整表格数据,例如带文本内容的 HTML / Markdown 表格;使用时一般不需要再额外通过 placeholders 和 contents 拼回单元格内容。
- 因此,fast 更适合需要自行处理表格骨架和单元格文本映射的场景;hq 更适合直接消费完整表格结构的场景。高质量模式耗时通常更长;如果高质量服务不可用,系统会回退到可用的快速表格解析服务。
- 表格模式只影响表格区域的结构识别与单元格内容识别。表题、表注以及表格外正文仍主要受
textual 配置影响;如果希望表格内文字和正文都尽量高质量,通常同时设置 table=2 和 textual=2。
输出配置
解析任务的 token 用于后续结果获取。通过 /get-formatted 获取格式化结果时,可以用输出开关控制返回内容:
注意:结果获取接口使用 JSON body。调用 UniParser-API 时请设置 Content-Type: application/json;未传字段会使用默认值。
| 开关 |
默认值 |
返回字段类型 |
说明 |
content |
true |
str |
返回格式化后的全文内容,适合 LLM、搜索和阅读场景 |
objects |
false |
list[dict] |
返回扁平语义块列表;每项包含 class、confidence、float_xyxy、page、str 等字段,适合需要坐标、类型和块级内容的场景 |
pages_dict |
false |
list[list[dict]] |
返回按页组织的扁平布局;每一页是一个布局块列表,适合页级结构化处理 |
pages_tree |
false |
list[list[dict]] |
返回按页组织的树形布局;保留父子层级关系,适合需要层级结构的场景 |
molecule_source |
false |
控制选项 |
开启后在结构化结果中保留分子原始源信息;默认关闭是为了减少响应体积,关闭时会清空分子块的 source |
marginalia |
true |
控制选项 |
控制格式化结果中是否保留页边/边栏信息;默认保留是为了尽量不丢失原文信息 |
/get-formatted 可以为各语义元素指定输出格式:textual、table、molecule、chart、figure、expression、equation。
阶段提示:FormatFlag 属于获取结果阶段,只控制返回文本的格式;不要在 trigger 请求或 trigger_file 中使用它。
| 取值 |
名称 |
说明 |
示例 |
plain |
Plain |
纯文本,无前后缀 |
ATP inhibits ATR. |
markup |
Markup |
标记文本,默认值 |
\begin{paragraph}ATP inhibits ATR.\end{paragraph} |
markdown |
Markdown |
Markdown 格式,适合 LLM / 文档 |
## Results、- IC50: 0.5 nM |
latex |
Latex |
LaTeX,特别适合公式 |
$E = mc^2$ |
html |
Html |
HTML,特别适合表格 |
<table>...</table> |
objects、pages_dict、pages_tree 这三类结构化返回不会受 FormatFlag 影响;格式化主要作用于 content 和 objects 中的文本字段。
常见版面类型 LayoutType
在 objects、pages_dict、pages_tree 中,每个解析块都会带有 type 字段,用于描述该块在文档版面中的语义类型。
| 类型 |
含义 |
通常归属的大类 |
documenttitle |
文档标题 |
textual |
title |
章节标题 |
textual |
paragraph |
普通段落正文 |
textual |
abstract |
摘要 |
textual |
reference |
参考文献 |
textual |
table |
表格主体 |
table |
tablecaption / tablefootnote |
表题 / 表注 |
textual,语义上附属于表格 |
equation / equationinline |
独立公式 / 行内公式 |
equation |
molecule / moleculeid |
分子结构 / 分子编号 |
molecule 或相关文本 |
figure / image |
图片、插图、照片或图像区域 |
figure |
figurecaption / imagecaption |
图题 / 图片标题 |
textual,语义上附属于图片 |
expression / expressioncaption |
化学反应式 / 反应式标题 |
expression 或相关文本 |
chart / legend |
图表 / 图例 |
chart 或相关文本 |
pageheader / pagefooter / pagenumber |
页眉、页脚、页码 |
页边信息 |
group / tablegroup / figuregroup / moleculegroup |
组合节点 |
结构节点,常见于 pages_tree |
type 是结果标签,不等同于提交任务时的 textual、table、molecule 等解析配置项。
API 与前端限制
UniParser 会同时检查 API 账号额度和前端上传限制。API 限制由账号类型、权限和申请配置决定,并同时适用于直接上传及 URL/对象存储下载;前端限制只影响网页上传,不代表 API 账号的最终可解析额度。URL/对象存储下载还受服务端全局下载上限约束,实际采用账号额度与全局上限中更严格的值。
| 限制类型 |
适用对象 |
默认限制 |
说明 |
| API 文件体积 / 页数 |
访客标准账号 |
200 MB,2000 页 |
超出后会返回文件大小或页数限制相关错误 |
| API 文件体积 / 页数 |
付费用户 / 已开通高额度账号 |
默认 300 MB,6000 页 |
具体额度以 API 申请文档或账号开通配置为准,可按需申请调整 |
| 前端上传体积 |
网页端上传 |
300 MB |
仅限制前端页面可上传的文件大小;直接调用 API 时仍以账号 API 限制为准 |
请求频率限制按账号、接口和服务端配置生效。触发限速时接口会返回 429,错误信息通常包含当前命中的限制;批量任务建议使用异步提交、控制并发,并在重试时增加退避等待。如需更高请求频率或更高文件额度,请在申请 API 权限时一并说明。
错误码清单 ErrorFlag
| 类别 |
常见错误 |
说明 |
处理建议 |
请求参数错误 400 |
Token_Required:缺少 token 参数
Token_Invalid:token 含非法字符,只允许字母、数字、下划线和短横线
Token_Duplicated:token 已存在且任务未完成
File_Required:缺少上传文件
File_Invalid:PDF 无效或页数为 0
URL_Invalid:URL 不合法、不可访问或下载内容不是支持的 PDF/图片格式
Request_Invalid:请求参数格式或取值非法 |
必填参数、文件内容、URL 可访问性或字段取值不符合要求 |
补齐必填字段;为原生 API 重新生成唯一 token;确认文件可打开、URL 可下载,并按文档取值传参 |
解析状态错误 400 |
Status_Not_Found:找不到该 token 对应的状态文件
Status_Decode_Failed:状态 JSON 损坏或无法解析
Result_Not_Found:解析结果文件不存在
Result_Decode_Failed:结果 JSON 损坏或无法解析 |
通常说明任务不存在、结果已清理、任务失败,或服务端缓存文件异常 |
确认使用的是提交时返回的同一个 token;异步任务先等待完成再获取;持续缺失时携带 token 联系支持,确认原任务和付款状态后再决定是否重提 |
语言和页面错误 400 |
Lang_Unknown:无法判断文档语言
Lang_Not_Supported:当前语言不支持对应 OCR / 解析流程
Pages_Required:特定接口缺少页码选择 |
文档语言、扫描质量或页码选择不满足解析要求 |
检查文档是否可读;必要时指定页码或换用支持语言的文档;扫描件建议提升图像质量 |
用户限制错误 400 |
File_Size_Exceeded:文件大小超过账号权限
PDF_Pages_Exceeded:PDF 页数超过账号权限
File_Type_Not_Allowed:文件类型不在允许列表中
Domain_Not_Allowed:URL 下载域名不在允许列表中 |
和账号权限、文件大小、页数、文件类型、下载域名白名单有关 |
压缩或拆分文件;换用允许的文件类型或域名;如需更高额度或权限,请联系我们开通 |
系统和处理错误 400/500 |
OS_Error:服务端文件 IO、路径、权限或系统资源错误(URL 下载接口返回 500)
Process_Failed:解析子任务执行失败,可能由模型、输入文件或运行环境导致 |
文件读写、模型服务或任务进程异常;OS_Error 不表示用户 URL 无效 |
保留 token 和错误响应,稍后重试;若持续失败,请携带文件、token 和错误信息反馈 |
认证和授权错误 401/402/403 |
Authentication required:缺少 Authorization 或 X-API-Key
Authentication failed:JWT Token 或 API-Key 无效 / 过期
Insufficient balance:账户余额不足
Administrator privileges required:接口需要管理员权限
Missing permission:账号缺少指定解析权限 |
请求头、API-Key、余额或权限不满足要求 |
检查 X-API-Key 是否正确、未过期且有余额;需要管理员或特殊解析权限时联系我们开通 |
速率限制错误 429 |
Rate limit exceeded: <limit>:超出全局或接口限速
Rate limit exceeded, <user_rate_limit>:超出用户级限速 |
请求频率或并发超过限制 |
降低并发和重试频率,增加退避等待;批处理请排队提交,必要时申请更高限速 |
文件与下载失败
页数无法确定时可能返回 422 / INVALID_PAGE_SELECTION,不表示已扣款。结合 pdf_error_code 区分空文件、需密码、非 PDF、无有效页或打开失败;上传完整、可读取且无需密码的文件后再提交。具体原因见 description / message。
下载失败通过 error_code 区分超时、超限、连接或存储错误。input_retained=true 表示服务保留了已收到的数据供排查,partial_input=true 表示数据可能不完整,并不表示任务可以继续解析;保留文件仍受缓存策略约束。联系支持时提供 token 和错误码,无需发送 API Key。
成功后收费与待付款
- 价格与来源:普通文档 0.05 元 × 请求解析页数;单元素 0.01 元/次。本地余额优先,不足时使用符合条件的 Bohrium 钱包。恢复付款沿用原任务的金额和付款来源。
- 收费时机:提交时检查余额,不预占资金;解析失败不收费。成功后保存结果并扣款,确认付款后才开放结果并发送成功回调。
- 响应处理:准入余额不足返回
402;无法确认钱包余额返回 503,可稍后重试。同步提交也可能返回 202、status=waiting、payment_pending=true。查询返回 200 也不一定完成,须检查 status。
- 继续查询:用同一账号和 token 调用
/get-result、/get-formatted 或 /get-third-party-output,可触发已完成任务的付款恢复,无需重传文件。仅订阅 /task-events 不会触发此恢复。余额不足时补足原付款来源;付款未知时只对账,不盲目重扣。只读余额复查默认间隔 60 秒,付款失败后可能进一步退避。
- 结果保留:明确未付款结果默认保留 7 天,到期返回
UNPAID_RESULT_EXPIRED;付款未知任务继续保留并对账。客户端超时不等于解析失败,请先查询原 token。
User Authentication
UniParser-API uses the X-API-Key request header. On the UniParser homepage, sign in with Bohrium (玻尔登录) for one-click authorization to obtain an API-Key (a trial balance is granted on first sign-in), or paste an existing API-Key directly. For higher quotas, broader permissions, or a long-term account, please contact us.
Payment is collected after successful parsing; results are released after payment confirmation. See “Success-only billing and pending payment” below for pricing, responses, and recovery.
# Generate a UUID once per new task; keep this variable for result queries (requires Python 3).
uniparser_token="$(python3 -c 'import uuid; print(uuid.uuid4().hex)')"
curl -X POST "https://uniparser.dp.tech/trigger-file-async" \
-H "X-API-Key: your_api_key" \
-F "token=${uniparser_token}" \
-F "file=@example.pdf" \
-F "sync=true"
Store the key in an environment variable such as UNIPARSER_API_KEY instead of hard-coding it in source code.
| Endpoint |
Request format |
Notes |
/trigger-file-async |
multipart/form-data |
Upload a PDF in the file field; other parameters are also form fields |
/trigger-snip-async / /trigger-url-async |
JSON body |
Image snippet or URL parsing requests |
/trigger-item-async |
application/x-www-form-urlencoded |
Individual-element parsing with Base64 img; see the example |
/get-result / /get-formatted / /get-third-party-output |
JSON body (POST) |
Query status or retrieve the corresponding result format using the original token |
Note: token is the unique task identifier. The individual-element endpoint generates it if omitted, but providing and saving one yourself helps recover results after a timeout. For other trigger endpoints, supply a token as shown in their examples. Generate a UUID per new task when calling directly through curl or Python; UniParser-Tools document parsing methods generate tokens automatically.
Duplicate submission reminder: generate a new UUID for each new task and reuse its token when fetching results. Submitting the same token again may return Token is duplicated; after a client timeout, check the original task before resubmitting or starting another task with a new token.
sync controls how the trigger request waits: sync=false is the default asynchronous mode and returns task status plus token immediately, so you fetch results later with the same token; sync=true waits in the submit request until parsing finishes or times out, which is convenient for examples, debugging, and small files. For large files or batch processing, prefer async mode and set timeout according to task size (default: 1800 seconds).
Task status and progress
HTTP status describes request handling, status describes the task, and billing_status describes billing. They are not interchangeable. undefined is an existing task status; success-only billing adds billing stages and waiting descriptions.
status |
Meaning and action |
undefined |
Receiving or preparing the task, or no parser progress is available yet; keep the token and poll |
waiting |
Waiting for initialization, parsing, or payment confirmation; check billing fields for context |
processing |
Parsing; show progress when available and continue polling |
success |
Results are available; payment is confirmed when success-only billing is enabled |
error |
The task failed; inspect the error description and code rather than polling indefinitely |
For example, this response is a waiting state, not a parse failure or evidence of insufficient funds or a completed charge:
{
"status": "undefined",
"description": "等待解析或付款完成",
"billing_status": "awaiting_parse",
"message": null,
"proc_page": null,
"total_page": null
}
The description means “Waiting for parsing or payment to complete.” awaiting_parse means a quote is saved for collection after successful parsing; it may remain throughout parsing. created / preordering / paying describe collection in progress, payment_unknown an unconfirmed payment outcome, and paid confirmed payment. declined can mean insufficient funds, a failed parse, or expiry; check status, billing_code, and the description together.
- Missing or
null page counters mean progress is unavailable, not zero pages or failure. Calculate a percentage only with valid numeric counters and a positive total. Even 100% does not establish result availability.
payment_pending=true means payment is not yet confirmed. This field may be absent; absence does not establish payment. message may also be null.
description / message are display text and may change. Do not match their wording to determine status; tolerate additional response fields.
- Query with the original account and token. Read results only on
success; handle error as a failure. For an unknown status, keep the token and record the response rather than resubmitting. Contact support with the token if waiting persists.
After a definite payment refusal, topping up or only waiting for a webhook does not retry payment. Use the original account and token with POST /get-result, POST /get-formatted, or POST /get-third-party-output to trigger recovery.
Oversized upload compatibility change: the response is now HTTP 413 (previously 400), and the description has changed. Identify it by error_code="FILE_SIZE_EXCEEDED", not the old status code or description text.
Parsing Options SemanticType
When submitting a parsing task, you can control these semantic element fields:
Stage note: SemanticType and ParseMode / ParseModeTextual belong to the submit stage. They decide what to parse and at what quality; do not use them in /get-formatted or get_formatted.
| Field |
Meaning |
Available modes |
textual |
Prose text, headings, footnotes, etc. |
0 / 1 / 2 / 3 / -1 / -3 |
equation |
Display mathematical equations |
0 / 1 / 2 / -1 / -3 |
table |
Tables |
0 / 1 / 2 / -1 / -3 |
chart |
Charts |
0 / 1 / -1 / -3 |
figure |
Figures, illustrations, photos |
0 / 1 / -1 / -3 |
expression |
Chemical reaction expressions |
0 / 1 / -1 / -3 |
molecule |
Chemical molecular structures |
0 / 1 / -1 / -3 |
Value notes: 0 disables parsing, 1 uses fast parsing, 2 uses high-quality parsing, -1 returns the original image as Base64, and -3 uploads the cropped image to TOS and returns a download URL without running OCR for that category. textual also supports 3 for direct text extraction from digital PDFs.
| Enum name |
Value |
ParseMode.DumpHosting / ParseModeTextual.DumpHosting |
-3 |
ParseMode.DumpBase64 / ParseModeTextual.DumpBase64 |
-1 |
ParseMode.OCRFast / ParseModeTextual.OCRFast |
1 |
ParseMode.OCRHighQuality / ParseModeTextual.OCRHighQuality |
2 |
ParseModeTextual.DigitalExported |
3 (textual only) |
Note: chart, expression, and molecule currently do not have a high-quality mode.
Image Storage in TOS (-3)
Set the desired category when submitting a request, for example figure=-3. All semantic categories listed above support this mode. On success, the result block's source contains an HTTP(S) GET download URL, which is also used in Markdown/HTML output.
URLs expire 7 days after signing by default; the actual expiration is determined by the URL provided by the service. Reading results again does not renew URLs. Download and save images before expiration, and keep signed URLs intact without changing the hostname or query parameters.
If an image upload or download URL generation fails, that block returns the original image as Base64, as in DumpBase64=-1, while other images continue processing. dict_cfg retains the requested mode -3, so a task's source values may contain both URLs and Base64. Handle each block accordingly when consuming results directly; Markdown/HTML automatically converts fallback images to data URIs.
Table Mode: fast vs hq
table=1 (fast) returns a combination of a structure template and cell text. You usually need structure, placeholders, and contents together to reconstruct the table: structure describes the table skeleton, placeholders mark cell placeholders, and contents provides the corresponding cell text.
table=2 (hq) usually puts the complete table data directly in structure, such as an HTML / Markdown table with text content. In this mode, you generally do not need to stitch cell content back from placeholders and contents.
- Therefore, fast is better when you want to handle the mapping between table skeleton and cell text yourself; hq is better when you want to consume a complete table structure directly. High-quality mode usually takes longer; if the high-quality service is unavailable, UniParser falls back to an available fast table parser.
- Table mode only affects table-region structure recognition and cell-content recognition. Table captions, table footnotes, and surrounding body text are mainly controlled by
textual; when you want both table text and body text to use higher quality, usually set both table=2 and textual=2.
Output Switches
The task token is used for subsequent result fetching. Use /get-formatted with output switches to choose what to fetch:
Note: result-fetching endpoints use a JSON body. When calling UniParser-API directly, set Content-Type: application/json; omitted fields use default values.
| Switch |
Default |
Returned field type |
Description |
content |
true |
str |
Formatted full-document content, useful for LLMs, search, and reading |
objects |
false |
list[dict] |
Flat semantic block list. Each item includes fields such as class, confidence, float_xyxy, page, and str; useful when coordinates, block types, and block-level content are needed |
pages_dict |
false |
list[list[dict]] |
Flattened page-level layout. Each page is a list of layout blocks, useful for page-level structured processing |
pages_tree |
false |
list[list[dict]] |
Page-level tree layout that preserves parent-child hierarchy, useful when hierarchical structure is needed |
molecule_source |
false |
Control option |
Keeps original molecule source information in structured outputs. It defaults to disabled to reduce response size; when disabled, molecule block source is cleared |
marginalia |
true |
Control option |
Controls whether marginal / side-bar information is kept in formatted output. It defaults to enabled to avoid dropping source-document information |
/get-formatted can specify output formats for these semantic element fields: textual, table, molecule, chart, figure, expression, and equation.
Stage note: FormatFlag belongs to the result-fetching stage. It only controls the format of returned text; do not use it in trigger requests or trigger_file.
| Value |
Name |
Meaning |
Example |
plain |
Plain |
Plain text, no markers |
ATP inhibits ATR. |
markup |
Markup |
Marker-wrapped text, default |
\begin{paragraph}ATP inhibits ATR.\end{paragraph} |
markdown |
Markdown |
Markdown, suitable for LLMs and documents |
## Results, - IC50: 0.5 nM |
latex |
Latex |
LaTeX, especially useful for equations |
$E = mc^2$ |
html |
Html |
HTML, especially useful for tables |
<table>...</table> |
Structured outputs such as objects, pages_dict, and pages_tree are not affected by FormatFlag; formatting mainly applies to text fields in content and objects.
Common Layout Types LayoutType
In objects, pages_dict, and pages_tree, each parsed block has a type field describing what the block represents on the page.
| Type |
Meaning |
Usually belongs to |
documenttitle |
Document title |
textual |
title |
Section heading |
textual |
paragraph |
Main body paragraph |
textual |
abstract |
Abstract |
textual |
reference |
Reference entry |
textual |
table |
Table body |
table |
tablecaption / tablefootnote |
Table caption / footnote |
textual, semantically attached to a table |
equation / equationinline |
Display / inline equation |
equation |
molecule / moleculeid |
Molecular structure / molecule label |
molecule or related text |
figure / image |
Figure, illustration, photo, or image region |
figure |
figurecaption / imagecaption |
Figure / image caption |
textual, semantically attached to an image |
expression / expressioncaption |
Chemical reaction expression / caption |
expression or related text |
chart / legend |
Chart / legend |
chart or related text |
pageheader / pagefooter / pagenumber |
Header, footer, page number |
Marginal information |
group / tablegroup / figuregroup / moleculegroup |
Group node |
Structural node, common in pages_tree |
type is a result label. It is not the same layer as parsing options such as textual, table, or molecule.
API And Frontend Limits
UniParser checks both API account quotas and frontend upload limits. API limits depend on account type, permissions, and approved quota configuration, and apply to direct uploads as well as URL/object-storage downloads. Frontend limits only apply to uploads through the web page and do not represent the final parsing quota for direct API calls. URL/object-storage downloads are also constrained by the server-wide download limit; the stricter account or server limit is used.
| Limit type |
Applies to |
Default limit |
Notes |
| API file size / page count |
Visitor standard accounts |
200 MB, 2000 pages |
Requests beyond the quota return file-size or page-count limit errors |
| API file size / page count |
Paid users / accounts with higher quotas |
Default 300 MB, 6000 pages |
The actual quota follows the API application document or account provisioning configuration and can be adjusted on request |
| Frontend upload size |
Web upload page |
300 MB |
This only limits files uploaded from the frontend; direct API calls are still governed by the account API quota |
Request-rate limits are enforced by account, endpoint, and server-side configuration. When a request is rate-limited, the API returns 429, usually with the specific limit that was hit. For batch jobs, prefer asynchronous submission, control concurrency, and use backoff before retrying. If you need higher request throughput or larger file quotas, include that requirement in the API permission request.
Error Codes ErrorFlag
| Category |
Common errors |
Meaning |
What to do |
Request parameter errors 400 |
Token_Required: missing token parameter
Token_Invalid: token contains invalid characters; only letters, numbers, underscores, and hyphens are allowed
Token_Duplicated: token already exists and the task is not finished
File_Required: upload file is missing
File_Invalid: invalid PDF or zero-page PDF
URL_Invalid: URL is invalid, unreachable, or does not return a supported PDF/image format
Request_Invalid: request parameter format or value is invalid |
Required parameters, file content, URL accessibility, or field values are invalid |
Fill in required fields; generate a new unique token for native API calls; verify the file opens, the URL downloads, and field values match the docs |
Parsing status errors 400 |
Status_Not_Found: no status file found for the token
Status_Decode_Failed: status JSON is corrupted or cannot be decoded
Result_Not_Found: parsing result file does not exist
Result_Decode_Failed: result JSON is corrupted or cannot be decoded |
Usually means the task does not exist, the result was cleaned up, the task failed, or server-side cache files are abnormal |
Make sure you use the same token returned at submission; wait for async tasks to finish before fetching; contact support with the token if results remain missing; verify the original task and payment before resubmitting |
Language and page errors 400 |
Lang_Unknown: document language cannot be detected
Lang_Not_Supported: the language is not supported by the OCR / parsing flow
Pages_Required: page selection is missing for endpoints that require it |
Document language, scan quality, or page selection does not meet parsing requirements |
Check that the document is readable; provide pages when required; improve scan quality or use a supported-language document |
User limit errors 400 |
File_Size_Exceeded: file size exceeds account limits
PDF_Pages_Exceeded: PDF page count exceeds account limits
File_Type_Not_Allowed: file type is not allowed
Domain_Not_Allowed: URL download domain is not allowed |
Related to account permissions, file size, page count, file type, or domain allowlist |
Compress or split the file; use an allowed file type or domain; contact us for higher quotas or broader permissions |
System and processing errors 400/500 |
OS_Error: server-side file I/O, path, permission, or system resource error (500 from the URL download endpoint)
Process_Failed: parsing subprocess failed, possibly caused by the model, input file, or runtime environment |
File I/O, model service, or task process failed; OS_Error does not mean the user URL is invalid |
Keep the token and error response, retry later, and report the file, token, and error details if it keeps failing |
Authentication and authorization 401/402/403 |
Authentication required: missing Authorization or X-API-Key header
Authentication failed: JWT Token or API-Key is invalid / expired
Insufficient balance: account balance is not enough
Administrator privileges required: endpoint requires admin privileges
Missing permission: account lacks specific parsing permissions |
Headers, API-Key, balance, or permissions are insufficient |
Check that X-API-Key is correct, unexpired, and has balance; contact us for administrator or special parsing permissions |
Rate limit errors 429 |
Rate limit exceeded: <limit>: global or endpoint limit exceeded
Rate limit exceeded, <user_rate_limit>: user-level rate limit exceeded |
Request frequency or concurrency exceeds limits |
Reduce concurrency and retry frequency, add backoff, queue batch jobs, or request a higher rate limit |
File and download failures
An undetermined page count may return 422 / INVALID_PAGE_SELECTION; this does not indicate a charge. Use pdf_error_code to distinguish empty files, password requirements, non-PDF content, missing pages, and open failures. Submit a complete, readable, password-free file after correcting the problem; see description / message for details.
Download failures use error_code to distinguish timeouts, size limits, connection failures, and storage errors. input_retained=true means received bytes were kept for diagnosis; partial_input=true means they may be incomplete, not that parsing can proceed. Retained inputs remain subject to cache policy. Give support the token and error code, never your API Key.
Success-only billing and pending payment
- Price and source: Documents cost CNY 0.05 × requested pages; individual-element parsing costs CNY 0.01 per request. Local balance is preferred, followed by an eligible Bohrium wallet. Recovery keeps the original amount and payment source.
- Collection: Submission checks funds without reserving them. Failed parses are not charged. Successful results are saved before collection and released, with success callbacks, only after payment confirmation.
- Responses: Insufficient funds at admission return
402; an unavailable wallet balance check returns 503 and can be retried later. Even synchronous submission may return 202, status=waiting, and payment_pending=true. A result query returning 200 is not necessarily complete: check status.
- Polling: Use the same account and token with
/get-result, /get-formatted, or /get-third-party-output to trigger payment recovery for completed tasks without uploading again. Subscribing only to /task-events does not trigger this recovery. Top up the original payment source if needed. Unknown payments are reconciled, not blindly charged again. Read-only balance checks default to a 60-second interval; payment failures may back off further.
- Retention: Definitively unpaid results are retained for 7 days by default, then report
UNPAID_RESULT_EXPIRED. Unknown payments remain pending for reconciliation. A client timeout does not establish a parsing failure: query the original token first.