Skip to main content

docparse

LLM-powered document extraction SDK. Extract structured data from PDFs, invoices, contracts, and any custom schema — in two lines of Python.

from docparse import LLMExtractor, load, INVOICE_SCHEMA

layout = load("invoice.pdf")                        # or from_text("...")
result = LLMExtractor().extract(layout, INVOICE_SCHEMA)

print(result.get("total_amount"))        # 1500.0
print(result.confidence("vendor_name"))  # 0.97

Installation

pip install docparse                # core (text files only)
pip install "docparse[pdf]"         # + PDF support via pdfplumber
pip install "docparse[openai]"      # + OpenAI provider
pip install "docparse[anthropic]"   # + Anthropic provider
pip install "docparse[all]"         # everything

Quickstart

from docparse import LLMExtractor, from_text, INVOICE_SCHEMA

layout = from_text("""
INVOICE #INV-2024-042
Vendor: Acme Corp
Date: 2024-03-15
Total: $1,500.00
""")

extractor = LLMExtractor(model="gpt-4o-mini", provider="openai")
result = extractor.extract(layout, INVOICE_SCHEMA)

for field_name in INVOICE_SCHEMA.field_names():
    value = result.get(field_name)
    conf  = result.confidence(field_name)
    if value is not None:
        print(f"{field_name}: {value}  (confidence: {conf:.0%})")

Built-in schemas

Schema constant Key Fields
INVOICE_SCHEMA invoice 12 fields — amounts, dates, vendor, line items
LOAN_APPLICATION_SCHEMA loan_application 12 fields — borrower, amounts, property
W2_SCHEMA w2 8 fields — employer, wages, withholdings
NDA_SCHEMA nda 8 fields — parties, term, jurisdiction
CONTRACT_SCHEMA contract 9 fields — parties, dates, obligations

Access any by key: from docparse import REGISTRY; schema = REGISTRY["invoice"]

Custom schemas

from docparse import ExtractionSchema, FieldSpec, LLMExtractor, from_text

schema = ExtractionSchema(name="purchase_order", fields=[
    FieldSpec(name="po_number",     description="PO number",         required=True),
    FieldSpec(name="total",         description="Total amount",       type="number", required=True, example="4200.00"),
    FieldSpec(name="delivery_date", description="Expected delivery",  type="date"),
])

result = LLMExtractor().extract(from_text(po_text), schema)
missing = result.missing_required(schema)

CLI

docparse extract invoice.pdf --schema invoice
docparse extract contract.txt --schema nda --json
docparse schemas          # list available schemas

Providers

# OpenAI (default)
LLMExtractor(model="gpt-4o-mini", provider="openai")

# Anthropic
LLMExtractor(model="claude-3-5-haiku-20241022", provider="anthropic")

License

MIT © Mawlaia

Metadata

Release files for mawlaia-docparse 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mawlaia-docparse 0.4.0
File Size Uploaded Provenance
mawlaia_docparse-0.4.0.tar.gz 9.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mawlaia-docparse 0.4.0
File Interpreter ABI Platform
mawlaia_docparse-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.8 kB

Release files / mawlaia_docparse-0.4.0.tar.gz

Download URL mawlaia_docparse-0.4.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8a630c58055e079b135df2916d447e26d6baad38de89faa14eb9525c5e16f134
BLAKE2b-256 checksum
How to use checksums
042604eb5fc0af305131d3fe5970382f5f530c10f0aa6a8071e42af3fcb0326d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.3 Darwin/25.3.0

Release files / mawlaia_docparse-0.4.0-py3-none-any.whl

Download URL mawlaia_docparse-0.4.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30c4f26fb05d8a00c4ae59df2e653e1919e89b8ff30dc4058fcdfbee05f9fdae
BLAKE2b-256 checksum
How to use checksums
db3a7173cc4d781d68d12b95bfded3a3978642abc70d23786ef824a1b54d7866
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.3 Darwin/25.3.0

Security for mawlaia-docparse 0.4.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page