Skip to main content

Quickstart

Extract structured data from a document in under 2 minutes.

Prerequisites

Step 1: Extract Data from a Document

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

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:

result = client.extract("invoice.pdf", 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:

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")

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:

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}")

What's Next