Best for
Sync parsing is best for small files and use cases that require immediate results.
- Endpoint:
POST /parse/sync
- Return mode: result is returned directly in the same response
Request examples
The following examples request both md and json outputs.
curl -X POST https://somark.tech/api/v1/parse/sync \
-F "file=@document.pdf" \
-F "output_formats=markdown" \
-F "output_formats=json" \
-F "api_key=sk-your-api-key"
Response example
{
"code": 0,
"message": "Task success",
"data": {
"task_id": "a1b2c3d4e5f6",
"error": null,
"metadata": {
"page_num": 10,
"file_type": ".pdf"
},
"result": {
"file_name": "document.pdf",
"outputs": {
"markdown": "# Chapter 1 Introduction\n\nThis document describes...",
"json": {
"pages": [
{
"page_num": 0,
"blocks": [
{
"idx": 0,
"type": "title",
"bbox": [72, 50, 540, 80],
"content": "Chapter 1 Introduction",
"format": "text",
"captions": [],
"img_url": "",
"title_level": 1
},
{
"idx": 1,
"type": "text",
"bbox": [72, 100, 540, 200],
"content": "This document describes...",
"format": "text",
"captions": [],
"img_url": ""
}
],
"page_size": { "h": 1684, "w": 1190 },
"merge_content_from_pre_page": false
}
]
}
}
}
}
}
If code is not 0, first check whether api_key is valid, whether output_formats uses markdown/json/zip, and whether the uploaded file is empty.
Further reading
See the full sync parsing endpoint details.