Skip to main content

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"),
    root_url=os.environ.get("DOCUMENTEXTRACTOR_API_URL"),
)

# Upload a Document
file = api.files.upload(
    os.path.join(os.path.dirname(__file__), "example_invoice.pdf")
)

# 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",
    type="Text",
    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", type="Number", is_array=False),
    ],
),
))

try:
    # 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))
except Exception as e:
    print(f"Error extracting data: {e}")

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

documentextractor-0.3.1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

documentextractor-0.3.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file documentextractor-0.3.1.tar.gz.

File metadata

  • Download URL: documentextractor-0.3.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for documentextractor-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7624f47d1752209e78d57e2f265033ed4cf3c92d013d73965cd92178a9f5ab7b
MD5 71850f28211a55a6ee6d70547eb3cfa4
BLAKE2b-256 58b922188f35c3c8c5938252a3988c4c0fb89dcf646bfa3cdb7cad008d654f8b

See more details on using hashes here.

File details

Details for the file documentextractor-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for documentextractor-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 537244f7c8663dca14a56d8e410aef7f141a638f0f77a4fa657ca279b863d7f6
MD5 556bc8a1603109c60268e0997439fc51
BLAKE2b-256 8a4728ef0a7ce4d01cad4b5041b04dbc619237a2b86272a7c040b1c6bc6db1d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page