跳转到主要内容
POST
/
parse
/
async_check
Python
import time
import requests

url = "https://somark.tech/api/v1/parse/async_check"
task_id = "c5e6c983f28a4e6eb5d6c061343a8642"

while True:
    response = requests.post(url, data={
        "task_id": task_id,
        "api_key": "sk-***",
    })
    result = response.json()
    status = result["data"]["status"]

    if status == "success":
        print(result["data"]["result"])
        break
    elif status == "failed":
        print("解析失败")
        break

    time.sleep(3)
{
  "code": 0,
  "message": "查询成功",
  "data": {
    "record_id": 12345,
    "task_id": "c5e6c983f28a4e6eb5d6c061343a8642",
    "status": "success",
    "file_name": "document.pdf",
    "metadata": {
      "page_num": 5,
      "file_type": ".pdf"
    },
    "result": {
      "file_name": "document.pdf",
      "outputs": {
        "markdown": "# 第一章 引言\n\n本文档介绍了...",
        "json": {
          "pages": [
            {
              "page_num": 0,
              "blocks": [
                {
                  "idx": 0,
                  "type": "title",
                  "bbox": [
                    72,
                    50,
                    540,
                    80
                  ],
                  "content": "第一章 引言",
                  "format": "text",
                  "captions": [],
                  "img_url": "",
                  "title_level": 1
                },
                {
                  "idx": 1,
                  "type": "text",
                  "bbox": [
                    72,
                    100,
                    540,
                    200
                  ],
                  "content": "本文档介绍了...",
                  "format": "text",
                  "captions": [],
                  "img_url": ""
                }
              ],
              "page_size": {
                "h": 1684,
                "w": 1190
              },
              "merge_content_from_pre_page": false
            }
          ]
        }
      }
    }
  }
}
路径变更:该接口路径已从 /extract/async_check 更改为 /parse/async_check。旧路径将于 2026-12-31 停用,请在此之前迁移至新路径。

任务状态

status含义
queuing排队等待处理
processing解析进行中
success解析成功,result 字段有值
failed解析失败
建议每隔 3~5 秒轮询一次,直到 statussuccessfailed

请求体

multipart/form-data
task_id
string
必填

提交任务时返回的任务 ID

api_key
string
必填

API 密钥,格式 sk-***

响应

200 - application/json

查询成功

code
integer

状态码,0 为成功,非 0错误码

示例:

0

message
string
示例:

"查询成功"

data
object