Endpoints
Sync parsing
Upload a file and get the parsing result immediately
POST
/
parse
/
sync
Python
import json
import requests
url = "https://somark.ai/api/v1/parse/sync"
data = {
"output_formats": ["markdown", "json"],
"api_key": "sk-***",
"element_formats": json.dumps({
"image": "url",
"formula": "latex",
"table": "html",
"cs": "image",
}),
"feature_config": json.dumps({
"enable_text_cross_page": False,
"enable_table_cross_page": False,
"enable_title_level_recognition": False,
"enable_inline_image": False,
"enable_table_image": True,
"enable_image_understanding": True,
"keep_header_footer": False,
}),
}
files = {"file": ("example.pdf", open("example.pdf", "rb"))}
response = requests.post(url, data=data, files=files)
print(response.json())curl -X POST https://somark.ai/api/v1/parse/sync \
-F "file=@example.pdf" \
-F "output_formats=markdown" \
-F "output_formats=json" \
-F "api_key=sk-***" \
-F 'element_formats={"image":"url","formula":"latex","table":"html","cs":"image"}' \
-F 'feature_config={"enable_text_cross_page":false,"enable_table_cross_page":false,"enable_title_level_recognition":false,"enable_inline_image":false,"enable_table_image":true,"enable_image_understanding":true,"keep_header_footer":false}'const form = new FormData();
form.append('api_key', '<string>');
form.append('file', '<string>');
form.append('file_url', '<string>');
form.append('output_formats[0]', 'markdown');
form.append('output_formats[1]', 'json');
form.append('element_formats', '{
"image": "url",
"formula": "latex",
"table": "html",
"cs": "image"
}');
form.append('feature_config', '{
"enable_text_cross_page": false,
"enable_table_cross_page": false,
"enable_title_level_recognition": false,
"enable_inline_image": false,
"enable_table_image": true,
"enable_image_understanding": true,
"keep_header_footer": false
}');
const options = {method: 'POST'};
options.body = form;
fetch('https://somark.ai/api/v1/parse/sync', 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/sync",
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=\"api_key\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_url\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_formats%5B0%5D\"\r\n\r\nmarkdown\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_formats%5B1%5D\"\r\n\r\njson\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"element_formats\"\r\n\r\n{\r\n \"image\": \"url\",\r\n \"formula\": \"latex\",\r\n \"table\": \"html\",\r\n \"cs\": \"image\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"feature_config\"\r\n\r\n{\r\n \"enable_text_cross_page\": false,\r\n \"enable_table_cross_page\": false,\r\n \"enable_title_level_recognition\": false,\r\n \"enable_inline_image\": false,\r\n \"enable_table_image\": true,\r\n \"enable_image_understanding\": true,\r\n \"keep_header_footer\": false\r\n}\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/sync"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"api_key\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_url\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_formats%5B0%5D\"\r\n\r\nmarkdown\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_formats%5B1%5D\"\r\n\r\njson\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"element_formats\"\r\n\r\n{\r\n \"image\": \"url\",\r\n \"formula\": \"latex\",\r\n \"table\": \"html\",\r\n \"cs\": \"image\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"feature_config\"\r\n\r\n{\r\n \"enable_text_cross_page\": false,\r\n \"enable_table_cross_page\": false,\r\n \"enable_title_level_recognition\": false,\r\n \"enable_inline_image\": false,\r\n \"enable_table_image\": true,\r\n \"enable_image_understanding\": true,\r\n \"keep_header_footer\": false\r\n}\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/sync")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"api_key\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_url\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_formats%5B0%5D\"\r\n\r\nmarkdown\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_formats%5B1%5D\"\r\n\r\njson\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"element_formats\"\r\n\r\n{\r\n \"image\": \"url\",\r\n \"formula\": \"latex\",\r\n \"table\": \"html\",\r\n \"cs\": \"image\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"feature_config\"\r\n\r\n{\r\n \"enable_text_cross_page\": false,\r\n \"enable_table_cross_page\": false,\r\n \"enable_title_level_recognition\": false,\r\n \"enable_inline_image\": false,\r\n \"enable_table_image\": true,\r\n \"enable_image_understanding\": true,\r\n \"keep_header_footer\": false\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://somark.ai/api/v1/parse/sync")
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=\"api_key\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_url\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_formats%5B0%5D\"\r\n\r\nmarkdown\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_formats%5B1%5D\"\r\n\r\njson\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"element_formats\"\r\n\r\n{\r\n \"image\": \"url\",\r\n \"formula\": \"latex\",\r\n \"table\": \"html\",\r\n \"cs\": \"image\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"feature_config\"\r\n\r\n{\r\n \"enable_text_cross_page\": false,\r\n \"enable_table_cross_page\": false,\r\n \"enable_title_level_recognition\": false,\r\n \"enable_inline_image\": false,\r\n \"enable_table_image\": true,\r\n \"enable_image_understanding\": true,\r\n \"keep_header_footer\": false\r\n}\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "任务成功",
"data": {
"task_id": "a1b2c3d4e5f6",
"error": null,
"metadata": {
"page_num": 10,
"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/acc_sync to /parse/sync. The old path will be discontinued on December 31, 2026. Please migrate to the new path before then.
Parameter change: extract_config has been renamed to feature_config. Please replace extract_config with feature_config in your requests.output_formats
output_formats
| Available output formats | Default | Description |
|---|---|---|
json / markdown / zip | ["markdown", "json"] | Multiple selections supported. Uses the default when omitted. zip packages the Markdown output and all image files into an archive. When output_formats includes zip, element_formats.image must be file |
element_formats
element_formats
| Field | Available output formats | Default | Description |
|---|---|---|---|
image | url / base64 / file / none | url | Single selection only. When image is set to file, output_formats must include zip. none means images are not returned |
formula | latex / mathml / ascii | latex | Single selection only. Specifies the output format for formulas |
table | markdown / html / image | html | Single selection only. In markdown mode, merged cells are automatically split into independent cells and filled with the same content |
cs | image | image | Single selection only. Output format for chemical structures; smiles format is coming soon |
feature_config
feature_config
| Field | Default | Description |
|---|---|---|
enable_text_cross_page | false | Cross-page text merging: merge text blocks spanning pages into continuous paragraphs |
enable_table_cross_page | false | Cross-page table merging: merge tables spanning pages into a single table |
enable_title_level_recognition | false | Heading level recognition: detect document heading hierarchy (H1/H2/H3…) |
enable_inline_image | false | Inline images: return images inside text paragraphs |
enable_table_image | true | Images in tables: return images inside table cells |
enable_image_understanding | true | Image understanding: perform semantic understanding and structured description of document images |
keep_header_footer | false | Keep headers and footers: headers and footers are filtered by default; enable this if you need to preserve them |
If you need auth, usage limits, or sync vs async guidance, read the API overview first. For large files and batch jobs, switch to Async parsing — Submit Task.
Body
multipart/form-data
API 密钥,格式 sk-***
待解析的文档文件(与 file_url 二选一)
待解析文档的下载链接(与 file 二选一)
输出格式,可多选。不传时默认为 ["markdown", "json"]。支持 json / markdown / zip,其中 zip 将所有输出文件打包为压缩包
Available options:
json, markdown, zip 元素格式配置,控制各类元素的格式
Show child attributes
Show child attributes
特色功能配置(参数已从 extract_config 更名为 feature_config)
Show child attributes
Show child attributes
⌘I

