Quickstart
Extract structured data from a document in under 2 minutes.
Prerequisites​
- An API key from developers.qomplement.com (see Authentication)
- A document to process (PDF or image)
Step 1: Extract Data from a Document​
- cURL
- Python
- JavaScript
curl -X POST https://developer-api.qomplement.com/v1/extract \
-H "Authorization: Bearer sd_YOUR_API_KEY" \
-F "file=@invoice.pdf"
import requests
response = requests.post(
"https://developer-api.qomplement.com/v1/extract",
headers={"Authorization": "Bearer sd_YOUR_API_KEY"},
files={"file": open("invoice.pdf", "rb")},
)
result = response.json()
const form = new FormData();
form.append("file", new Blob([fs.readFileSync("invoice.pdf")]), "invoice.pdf");
const response = await fetch("https://developer-api.qomplement.com/v1/extract", {
method: "POST",
headers: { Authorization: "Bearer sd_YOUR_API_KEY" },
body: form,
});
const result = await response.json();
Step 2: Read the Response​
For small documents (≤5 pages), you get the result immediately:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"result": {
"model": "qomplement-OCR-v1",
"document_type": "invoice",
"language": "en",
"confidence": 95,
"fields": {
"invoice_number": "INV-2025-001234",
"total_amount": "1500.50",
"invoice_date": "2025-02-26",
"vendor_name": "ABC Corp"
},
"tables": [],
"pages_processed": 1,
"processing_time_ms": 3456
}
}
The fields object contains all extracted key-value pairs as a flat dictionary. Access values directly:
fields = result["result"]["fields"]
print(f"Invoice: {fields['invoice_number']}")
print(f"Total: ${fields['total_amount']}")
Step 3: Extract with a Schema (Optional)​
Tell the API exactly which fields you want for higher accuracy:
- cURL
- Python
- JavaScript
curl -X POST https://developer-api.qomplement.com/v1/extract \
-H "Authorization: Bearer sd_YOUR_API_KEY" \
-F "file=@invoice.pdf" \
-F 'schema=[{"name":"invoice_number","type":"string"},{"name":"total","type":"number"},{"name":"date","type":"date"}]'
import json
response = requests.post(
"https://developer-api.qomplement.com/v1/extract",
headers={"Authorization": "Bearer sd_YOUR_API_KEY"},
files={"file": open("invoice.pdf", "rb")},
data={
"schema": json.dumps([
{"name": "invoice_number", "type": "string"},
{"name": "total", "type": "number"},
{"name": "date", "type": "date"},
])
},
)
const form = new FormData();
form.append("file", new Blob([fs.readFileSync("invoice.pdf")]), "invoice.pdf");
form.append("schema", JSON.stringify([
{ name: "invoice_number", type: "string" },
{ name: "total", type: "number" },
{ name: "date", type: "date" },
]));
const response = await fetch("https://developer-api.qomplement.com/v1/extract", {
method: "POST",
headers: { Authorization: "Bearer sd_YOUR_API_KEY" },
body: form,
});
Step 4: Fill a PDF Form​
Upload a source document and a target PDF form:
- cURL
- Python
curl -X POST https://developer-api.qomplement.com/v1/fill/pdf \
-H "Authorization: Bearer sd_YOUR_API_KEY" \
-F "source_files=@invoice.pdf" \
-F "target_pdf=@form_template.pdf"
response = requests.post(
"https://developer-api.qomplement.com/v1/fill/pdf",
headers={"Authorization": "Bearer sd_YOUR_API_KEY"},
files={
"source_files": open("invoice.pdf", "rb"),
"target_pdf": open("form_template.pdf", "rb"),
},
)
job = response.json()
This returns a job ID (always async):
{
"id": "job-uuid-here",
"status": "processing",
"poll_url": "/v1/jobs/job-uuid-here"
}
Step 5: Fill an Excel Template​
Upload a source document and an Excel template:
- cURL
- Python
curl -X POST https://developer-api.qomplement.com/v1/fill/excel \
-H "Authorization: Bearer sd_YOUR_API_KEY" \
-F "source_files=@invoice.pdf" \
-F "target_excel=@report_template.xlsx" \
-F "fill_mode=smart"
response = requests.post(
"https://developer-api.qomplement.com/v1/fill/excel",
headers={"Authorization": "Bearer sd_YOUR_API_KEY"},
files={
"source_files": open("invoice.pdf", "rb"),
"target_excel": open("report_template.xlsx", "rb"),
},
data={"fill_mode": "smart"},
)
job = response.json()
Step 6: Poll for Results​
- cURL
- Python
curl https://developer-api.qomplement.com/v1/jobs/job-uuid-here \
-H "Authorization: Bearer sd_YOUR_API_KEY"
import time
while True:
status = requests.get(
f"https://developer-api.qomplement.com/v1/jobs/{job['id']}",
headers={"Authorization": "Bearer sd_YOUR_API_KEY"},
).json()
if status["status"] in ("completed", "failed"):
break
time.sleep(3)
When complete, download the filled file:
{
"id": "job-uuid-here",
"status": "completed",
"result": {
"download_url": "/v1/jobs/job-uuid-here/download",
"fields_filled": 8,
"fields_total": 12
}
}
What's Next​
- Extract Endpoint — Full parameter reference with Python, JavaScript, and Go examples
- Fill PDF — PDF form filling details and examples
- Fill Excel — Excel template filling with fill modes
- Jobs — Async job management
- Code Examples — Complete workflows including AI integration