qomplement
Python SDK for the Qomplement StructDatafy API — extract structured data from documents and fill PDF/Excel forms with AI.
Installation
pip install qomplement
Quick Start
from qomplement import Qomplement
client = Qomplement("sd_your_api_key")
# Extract data from any document
result = client.extract("invoice.pdf")
print(result.fields)
# {'invoice_number': '12345', 'client_name': 'Acme Corp', 'total': '$5,000.00'}
print(result.tables)
print(result.document_type) # 'invoice'
print(result.confidence) # 94
Extract
# Basic extraction
result = client.extract("document.pdf")
# With full detail (entities, summary, primary/secondary entities)
result = client.extract("document.pdf", detail=True)
print(result.detail["entities"])
print(result.detail["summary"])
# Guided extraction with schema
schema = [
{"name": "invoice_number", "type": "string"},
{"name": "total_amount", "type": "number"},
{"name": "vendor_name", "type": "string"},
]
result = client.extract("invoice.pdf", schema=schema)
# Extract with text chunking
result = client.extract("long_document.pdf", chunk_size=1000, chunk_overlap=200)
for chunk in result.chunks:
print(chunk["text"])
# From bytes
with open("document.pdf", "rb") as f:
result = client.extract(f.read(), filename="document.pdf")
Fill PDF
# Fill using source documents (AI extracts and maps fields)
result = client.fill_pdf(
"form.pdf",
source="invoice.pdf",
)
result.save("filled_form.pdf")
# Fill with natural language instructions
result = client.fill_pdf(
"contract.pdf",
instructions="Fill client name as 'Acme Corporation' and date as January 15, 2024",
)
result.save("filled_contract.pdf")
# Fill with explicit field mappings
result = client.fill_pdf(
"form.pdf",
field_mappings={"client_name": "Acme Corp", "date": "2024-01-15"},
)
result.save("filled_form.pdf")
print(f"Filled {result.fields_filled}/{result.fields_total} fields")
Fill Excel
# Fill Excel template from source documents
result = client.fill_excel(
"template.xlsx",
source="invoice.pdf",
)
result.save("filled_template.xlsx")
# Fill with instructions
result = client.fill_excel(
"template.xlsx",
instructions="Add company name as Acme Corp in the header",
)
result.save("filled.xlsx")
Async Jobs
Large documents (>5 pages) are processed asynchronously. By default, the SDK polls and waits for completion:
# This automatically waits for completion (default: wait=True)
result = client.extract("large_document.pdf")
# Get a job reference without waiting
job = client.extract("large_document.pdf", wait=False)
print(job.id) # job ID
print(job.status) # 'processing'
# Check job status later
job = client.get_job(job.id)
if job.status == "completed":
print(job.result)
# List your jobs
jobs = client.list_jobs(status="completed", limit=10)
Usage
usage = client.usage()
print(f"Requests: {usage.requests}")
print(f"Pages processed: {usage.pages_processed}")
# Usage for a specific month
usage = client.usage(period="2026-02")
Supported Formats
formats = client.formats()
print(formats["total_formats"]) # 33
# List available models
models = client.models()
for m in models:
print(f"{m['id']}: {m['description']}")
The API supports 33+ file formats including PDF, DOCX, XLSX, PPTX, CSV, TXT, RTF, images (PNG, JPEG, HEIC, TIFF), and legacy formats (DOC, XLS, PPT).
Configuration
# API key from environment variable
import os
os.environ["QOMPLEMENT_API_KEY"] = "sd_your_api_key"
client = Qomplement()
# Custom base URL
client = Qomplement("sd_your_api_key", base_url="https://developer-api-testing.qomplement.com")
# Custom timeout and max wait
client = Qomplement("sd_your_api_key", timeout=120, max_wait=300)
Error Handling
from qomplement import Qomplement, AuthenticationError, RateLimitError, ValidationError
client = Qomplement("sd_your_api_key")
try:
result = client.extract("document.pdf")
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except ValidationError as e:
print(f"Invalid request: {e}")
License
MIT
Metadata
Release files for qomplement 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qomplement-0.1.0.tar.gz | 11.1 kB | Without provenance | Details for qomplement-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qomplement-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for qomplement-0.1.0-py3-none-any.whl |
Total release size: 21.8 kB
Release files / qomplement-0.1.0.tar.gz
| Download URL | qomplement-0.1.0.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe93170739f45a99272b6115089ad31f5d6898254672a51c7ac01b184b2ea9e2
|
|
BLAKE2b-256 checksum How to use checksums |
489e217afa2b72e9165b50771581bc35f4dac308d99293535197bdadd28e7ae6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / qomplement-0.1.0-py3-none-any.whl
| Download URL | qomplement-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
95e70fffcb3bbd63b0e732ff68f03318771a5bf2ca2b0d5af040695bc5059738
|
|
BLAKE2b-256 checksum How to use checksums |
7031049966ae9d5a6db58615b0a5eb7efb3320cf369df32851f4f648ff238d11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for qomplement 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.