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)
- Optional: Install the SDK —
pip install qomplementornpm install qomplement
Step 1: Extract Data from a Document
- Python
- Node.js
- cURL
from qomplement import Qomplement
client = Qomplement("sd_YOUR_API_KEY")
result = client.extract("invoice.pdf")
print(result.fields) # {'invoice_number': '12345', 'total': '1500.50'}
print(result.document_type) # 'invoice'
print(result.confidence) # 94
import { Qomplement } from "qomplement";
const client = new Qomplement("sd_YOUR_API_KEY");
const result = await client.extract("invoice.pdf");
console.log(result.fields); // { invoice_number: '12345', total: '1500.50' }
console.log(result.documentType); // 'invoice'
console.log(result.confidence); // 94
curl -X POST https://developer-api.qomplement.com/v1/extract \
-H "Authorization: Bearer sd_YOUR_API_KEY" \
-F "file=@invoice.pdf"
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:
- Python
- Node.js
- cURL
result = client.extract("invoice.pdf", schema=[
{"name": "invoice_number", "type": "string"},
{"name": "total", "type": "number"},
{"name": "date", "type": "date"},
])
const result = await client.extract("invoice.pdf", {
schema: [
{ name: "invoice_number", type: "string" },
{ name: "total", type: "number" },
{ name: "date", type: "date" },
],
});
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"}]'
Step 4: Fill a PDF Form
Upload a source document and a target PDF form:
- Python
- Node.js
- cURL
result = client.fill_pdf("form_template.pdf", source="invoice.pdf")
result.save("filled_form.pdf")
print(f"Filled {result.fields_filled}/{result.fields_total} fields")
const result = await client.fillPDF("form_template.pdf", {
source: "invoice.pdf",
});
fs.writeFileSync("filled_form.pdf", result.fileBuffer);
console.log(`Filled ${result.fieldsFilled}/${result.fieldsTotal} fields`);
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"
The SDK automatically waits for completion and downloads the result. With cURL, you get a job ID to poll (see Jobs).
Step 5: Fill an Excel Template
Upload a source document and an Excel template:
- Python
- Node.js
- cURL
result = client.fill_excel("report_template.xlsx", source="invoice.pdf")
result.save("filled_report.xlsx")
print(f"Wrote {result.cells_written} cells in {result.sheets_modified}")
const result = await client.fillExcel("report_template.xlsx", {
source: "invoice.pdf",
});
fs.writeFileSync("filled_report.xlsx", result.fileBuffer);
console.log(`Wrote ${result.cellsWritten} cells in ${result.sheetsModified}`);
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"
What's Next
- Python SDK — Full Python SDK reference
- Node.js SDK — Full Node.js/TypeScript SDK reference
- Extract Endpoint — Full parameter reference
- Fill PDF — PDF form filling details and examples
- Fill Excel — Excel template filling with fill modes
- Jobs — Async job management
- Code Examples — Complete workflows