Official Python SDK for Invoice Data Extraction.
Project description
invoicedataextraction-sdk
Official Python SDK for Invoice Data Extraction. Handles file upload, extraction submission, polling, and result download so you can go from local files to structured output in a few lines of code.
- Python 3.9 or later
Install
pip install invoicedataextraction-sdk
Quick Start
import json
import os
import sys
from invoicedataextraction import InvoiceDataExtraction
from invoicedataextraction.errors import SdkError, ApiResponseError
try:
client = InvoiceDataExtraction(
api_key=os.environ.get("INVOICE_DATA_EXTRACTION_API_KEY"),
)
result = client.extract(
folder_path="./invoices",
prompt="Extract invoice number and total",
output_structure="per_invoice",
download={
"formats": ["xlsx", "json"],
"output_path": "./output",
},
console_output=True, # remove to disable console logging
)
except (SdkError, ApiResponseError) as error:
print(json.dumps(error.body, indent=2), file=sys.stderr)
raise SystemExit(1)
extract(...) uploads your files (pass a folder_path or a list of files), submits the extraction, polls until it finishes, and downloads the results. The returned result is the final polling response from the API. For completed responses, check result["pages"]["failed_count"] to verify that all uploaded pages were processed successfully, and check result["review_needed"]["count"] for any extracted values that require human verification before relying on the extracted data.
Generate an API key from your dashboard. Every account includes 50 free pages per month. Additional credits can be purchased on a pay-as-you-go basis with no subscription needed.
Staged Workflow
If you need control over individual steps — for example, uploading files in one part of your system and extracting in another — use the lower-level methods:
import json
import os
import sys
from invoicedataextraction import InvoiceDataExtraction
from invoicedataextraction.errors import SdkError, ApiResponseError
try:
client = InvoiceDataExtraction(
api_key=os.environ.get("INVOICE_DATA_EXTRACTION_API_KEY"),
)
upload = client.upload_files(
files=["./invoice1.pdf", "./invoice2.pdf"],
console_output=True,
)
submitted = client.submit_extraction(
upload_session_id=upload["upload_session_id"],
file_ids=upload["file_ids"],
prompt="Extract invoice number and total",
output_structure="per_invoice",
)
result = client.wait_for_extraction_to_finish(
extraction_id=submitted["extraction_id"],
console_output=True,
)
client.download_output(
extraction_id=submitted["extraction_id"],
format="xlsx",
file_path="./output/invoices.xlsx",
)
except (SdkError, ApiResponseError) as error:
print(json.dumps(error.body, indent=2), file=sys.stderr)
raise SystemExit(1)
Listing past extractions
# One-page browse with filters
page = client.list_extractions(
status="completed",
limit=50,
)
# Auto-paginating iterator over every matching extraction
for extraction in client.iterate_extractions(status="completed"):
print(extraction["extraction_id"], extraction["task_name"])
# Full record (the original prompt, options, full pages, full failure error, etc.)
result = client.get_extraction(extraction_id="...")
extraction = result["extraction"]
On listing methods, team admins can pass scope="team" to see extractions submitted by any team member; pass scope="own" to force own-only results.
Error Handling
SDK methods raise SdkError or ApiResponseError on failure. The structured error body is on error.body, with fields error.body["error"]["code"], error.body["error"]["message"], error.body["error"]["retryable"], and error.body["error"]["details"].
When an extraction task itself reaches a terminal state, extract(...) returns that response rather than raising — check result["status"] for "completed", "failed", or "cancelled" for tasks cancelled from the web app. See the full docs for details.
Documentation
- Python SDK docs — full method reference, parameters, return shapes, and examples
- REST API docs — endpoint-level documentation for direct HTTP integration
- Dashboard — manage API keys and view extraction results
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file invoicedataextraction_sdk-0.4.0.tar.gz.
File metadata
- Download URL: invoicedataextraction_sdk-0.4.0.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2ce76c202c3b283998d3dee322aa051e7e9d794ae9b22e6781809044cf7e584
|
|
| MD5 |
25bb4fcd185300ce09ed3542f6886ab9
|
|
| BLAKE2b-256 |
0bf8fb31f2848bc52d06831d6a8cc977d725d8e77ae858e1f30fb40eec23c2e6
|
File details
Details for the file invoicedataextraction_sdk-0.4.0-py3-none-any.whl.
File metadata
- Download URL: invoicedataextraction_sdk-0.4.0-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
851a81a74b5079aaf325b1e68c1e9d4b9b6044ace5b5ad8cad6d86710a18d054
|
|
| MD5 |
875d1ee0e3b9e82598f18f6cc064f210
|
|
| BLAKE2b-256 |
ad92d1981f6edac4b80d613729d36f2d4abfc5fd912855e7af91eb6605061707
|