Metadata-Version: 2.4
Name: localparse
Version: 0.1.0
Summary: Official Python client for the LocalParse document-parsing API (LlamaParse-compatible).
Project-URL: Homepage, https://localparse.com
Project-URL: Documentation, https://localparse.com/docs
Project-URL: Source, https://github.com/stevencoveta/Agent-ingestor
Author: LocalParse
License: MIT
Keywords: document parsing,llamaparse,localparse,ocr,pdf,tables
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing
Requires-Python: >=3.9
Requires-Dist: requests>=2.28
Description-Content-Type: text/markdown

# LocalParse — Python client

Official Python client for the [LocalParse](https://localparse.com) document-parsing
API. LocalParse is a **drop-in LlamaParse-compatible** parser with a deterministic
accuracy layer: table-detection recovery (catches tables a layout model misses)
and oracle-free **financial-identity checks** (flags `Total`s that don't reconcile).

## Install

```bash
pip install localparse
```

## Quickstart

```python
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:

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

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

## 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):

```python
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)

```python
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` — all subclass
`LocalParseError`.
