The official Python client for the DocumentExtractor API
Project description
DocumentExtractor.AI Python Client
A Python client for extracting structured data from documents using the DocumentExtractor API.
It provides convenient methods to upload documents, define extraction schemas, start extraction workflows, and retrieve structured results.
📦 Installation
pip install documentextractor
🚀 Quick Example
You can get started with just a few lines of code:
import os
from documentextractor import DocumentExtractorAPIClient, WorkflowCreate, SchemaCreate, RunCreate
api = DocumentExtractorAPIClient(
api_key=os.environ.get("DOCUMENTEXTRACTOR_API_KEY"),
)
# Define a workflow and extraction schema
workflow = api.workflows.create(payload=WorkflowCreate(
name="Simple Invoice Extraction",
extraction_schema=SchemaCreate(
name="Invoice Schema",
description="Extract invoice number and total amount",
is_array=False,
children=[
SchemaCreate(key="invoice_number", description="Sender-issued invoice number", type="Text", is_array=False),
SchemaCreate(key="total_amount", description="Total amount payable, in original currency", type="Number", is_array=False),
],
),
))
# Upload a Document
file = api.files.upload("example_invoice.pdf")
# Trigger a run
results = await workflow.runs.create_and_wait_for_results(payload=RunCreate(file_ids=[file.id]))
# Get structured results
extracted_items = results.extracted_data.raw
print(f"Found {len(extracted_items)} extracted item(s).")
if extracted_items:
# Pretty-print the structured data of the first result
print(" - Data from first result:")
import json
print(json.dumps(extracted_items[0].data, indent=2))
For the best experience, however, it's recommended to get more familiar with the client. For a full end-to-end usage script, see examples/basic_usage.py.
📄 License
Copyright © 2025 Philipp Heller
Licensed under the Apache License 2.0. You may not use this file except in compliance with the License.
See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 documentextractor-0.5.2.tar.gz.
File metadata
- Download URL: documentextractor-0.5.2.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d317537cfecf0bc987e60d3e7917f4354adc15a26d2692792cfac36504ee892
|
|
| MD5 |
9270e86939c6befbe0afa235bed2ab9a
|
|
| BLAKE2b-256 |
d73607164ddaff7f1e9ed5bfc480f21e9b382364845ce666e4df3a3f2c27ab71
|
File details
Details for the file documentextractor-0.5.2-py3-none-any.whl.
File metadata
- Download URL: documentextractor-0.5.2-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8d60a50ea141049bbb95b035040fe1af68e76de4c79d5b8924a59a926cb244f
|
|
| MD5 |
ce4d4a8963fa6c492c8d3a2fe06c5c79
|
|
| BLAKE2b-256 |
5cd260d3b7deeb503a330538bb64b4603cd8c4bcecaccd317f8a76b77444922a
|