Endpoints
Async parsing — Query Result
Query the status and result of an async task by task_id
POST
/
parse
/
async_check
Python
import time
import requests
url = "https://somark.ai/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)curl -X POST https://somark.ai/api/v1/parse/async_check \
-F "task_id=c5e6c983f28a4e6eb5d6c061343a8642" \
-F "api_key=sk-***"const form = new FormData();
form.append('task_id', '<string>');
form.append('api_key', '<string>');
const options = {method: 'POST'};
options.body = form;
fetch('https://somark.ai/api/v1/parse/async_check', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://somark.ai/api/v1/parse/async_check",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"api_key\"\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://somark.ai/api/v1/parse/async_check"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"api_key\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://somark.ai/api/v1/parse/async_check")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"api_key\"\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://somark.ai/api/v1/parse/async_check")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"task_id\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"api_key\"\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"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
}
]
}
}
}
}
}Path change: This endpoint path has been changed from
/extract/async_check to /parse/async_check. The old path will be discontinued on December 31, 2026. Please migrate to the new path before then.Task Status
status | Meaning |
|---|---|
queuing | Waiting in queue |
processing | Parsing in progress |
success | Parsing succeeded; result field is populated |
failed | Parsing failed |
status is success or failed. If you have not submitted the task yet, start with Async parsing — Submit Task; if you do not want polling, switch to Sync parsing; for failures, continue to Error Codes.⌘I

