Skip to main content

LocalParse — Python client

Official Python client for the LocalParse API. LocalParse gives you two products under one API:

  1. Parse — turn any document into clean Markdown, JSON, or text. Drop-in LlamaParse-compatible, plus a deterministic accuracy layer: table-detection recovery (catches tables a layout model misses) and oracle-free financial-identity checks (flags Totals that don't reconcile).
  2. Extract (Beta) — pull structured JSON out of parsed documents using your own JSON Schema. Server-side schema validation guarantees the returned object matches.

Install

pip install localparse

Quickstart — Parse

from localparse import LocalParse

client = LocalParse(api_key="lp-...")          # or set LOCALPARSE_API_KEY

result = client.parse("invoice.pdf", result_type="markdown")
print(result.markdown)

# Accuracy signal that plain OCR/LLM parsers don't give you:
print(result.identity_check)     # {tables_checked, violations, ...} or None
print(result.recovered_tables)   # tables recovered by detect_repair

Fetch JSON or the ingestion-ready structured contract instead:

result = client.parse("10k.pdf", result_type="json")
for page in result.pages:
    ...

structured = client.parse("10k.pdf", result_type="structured")

Quickstart — Extract (Beta)

Parse first to get clean markdown, then extract the fields you actually care about:

md = client.parse("invoice.pdf").markdown

invoice = client.extract(md, {
    "type": "object",
    "properties": {
        "vendor":     {"type": "string"},
        "invoice_no": {"type": "string"},
        "total":      {"type": "number"},
        "due_on":     {"type": "string", "description": "ISO 8601 date"},
    },
    "required": ["vendor", "total"],
})

print(invoice["vendor"], invoice["total"])

The server validates the model's output against your schema before returning: a non-conforming response surfaces as SchemaConformanceError rather than as silently broken data. Pre-flight safety failures (bad schema shape, depth/width caps, external $ref) surface as SchemaValidationError.

Persist a whole folder (incremental)

Ingest a data room into a named case; re-runs only parse new/changed files (unchanged files are skipped by content hash):

results = client.parse_folder(
    "./data-room",
    case_id="acme",
    resume=True,
    on_progress=lambda path, res: print("parsed" if res else "skipped", path),
)

Full control (async jobs)

job = client.upload("big.pdf", result_type="json", case_id="acme")
job = client.wait(job.id)
if job.is_success:
    result = client.get_result(job.id, "json")

Configuration

Argument Default Meaning
api_key LOCALPARSE_API_KEY env Bearer token for the API.
base_url https://api.localparse.com Point at a self-hosted instance if needed.
timeout 60 Per-request HTTP timeout (seconds).
poll_interval 2.0 Seconds between status polls in parse/wait.
max_wait 900 Max seconds to wait for a job before JobTimeoutError.

Errors

AuthenticationError (401/403), QuotaExceededError (402), NotFoundError (404), RateLimitError (429, with .retry_after), APIError (other non-2xx), JobFailedError (job ended ERROR/CANCELED), JobTimeoutError, SchemaValidationError (400 — bad data_schema), SchemaConformanceError (422 — model output didn't match the schema) — all subclass LocalParseError.

Metadata

Release files for localparse 0.2.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 localparse 0.2.0
File Size Uploaded
localparse-0.2.0.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for localparse 0.2.0
File Interpreter ABI Platform
localparse-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / localparse-0.2.0.tar.gz

Download URL localparse-0.2.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
78237d3225ac37396ad910aa68d9a7d1540afe34c25944decaf937cf7dafda31
BLAKE2b-256 checksum
How to use checksums
fe1e62233b99dadf1f3194af71b28d6ddd4add6d2fb2f8fe8ebb0b03c7cd370e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / localparse-0.2.0-py3-none-any.whl

Download URL localparse-0.2.0-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87b060d6cfc71a878db32b697f4509cf0d297aae5c046c467debac0201723358
BLAKE2b-256 checksum
How to use checksums
4a55e581cdb2da147480bd3f931de556db8df3346ecff9e72e1d1f26e473bd05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.5.0

2 release files

0.4.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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