Python SDK for the 0xPdf PDF-to-JSON API
Project description
oxpdf
Python SDK for the 0xPdf PDF-to-JSON API.
Installation
pip install oxpdf
Quick Start
from oxpdf import Client
client = Client(api_key="your_api_key")
# Parse with a built-in template
result = client.parse("invoice.pdf", schema_template="invoice")
print(result["data"])
# Parse with a custom schema
result = client.parse("doc.pdf", schema={
"type": "object",
"properties": {
"title": {"type": "string"},
"amount": {"type": "number"}
}
})
# Stream parse with real-time progress
for event in client.parse_stream("large.pdf", schema_template="invoice"):
if event["event"] == "page":
print(f"Progress: {event['data'].get('message')}")
elif event["event"] == "complete":
print("Done!", event["data"])
Error Handling
from oxpdf import Client, OxPDFError
client = Client(api_key="your_api_key")
try:
result = client.parse("doc.pdf", schema_template="invoice")
except OxPDFError as e:
print(f"API error: {e} (status: {e.status_code})")
except FileNotFoundError:
print("PDF file not found")
Full API Reference
Client
Client(api_key, base_url="https://api.0xpdf.io/api/v1")
PDF Parsing
| Method | Description |
|---|---|
parse(file_path, *, schema, schema_template, schema_id, use_ocr, ocr_engine, pages) |
Sync parse — returns structured JSON |
parse_stream(file_path, *, schema, schema_template, schema_id, use_ocr, ocr_engine, pages, batch_size) |
Streaming parse via SSE — yields events |
validate(file_path, *, schema_id, schema_name) |
Dry-run validation without processing |
Async Jobs
| Method | Description |
|---|---|
upload(file_path, *, schema_id, schema_name, use_ocr, ocr_engine) |
Queue PDF for background processing |
job_status(job_id) |
Poll async job status |
Image Extraction
| Method | Description |
|---|---|
extract_images(file_path, *, pages, min_width, min_height, use_ocr, ocr_engine) |
Extract images from a PDF |
list_images(*, limit, offset) |
List extracted images |
get_image_url(image_id, *, expiration_seconds) |
Get/refresh presigned URL |
delete_image(image_id) |
Delete a specific image |
delete_all_images() |
Delete all images |
File Management
| Method | Description |
|---|---|
list_files() |
List uploaded PDFs |
get_file(pdf_id) |
Get PDF metadata + download URL |
delete_file(pdf_id) |
Delete an uploaded PDF |
Schema CRUD
| Method | Description |
|---|---|
list_schemas() |
List saved schemas |
get_schema(schema_id) |
Get schema with full definition |
create_schema(name, schema, *, is_default) |
Create a new schema |
update_schema(schema_id, name, schema, *, is_default) |
Update existing schema |
delete_schema(schema_id) |
Delete a schema |
set_default_schema(schema_id) |
Set as default |
generate_schema(description, *, refinement, current_schema, selected_text) |
AI-generate a schema |
Templates
| Method | Description |
|---|---|
list_templates() |
Parse templates (invoice, receipt, etc.) |
list_schema_templates() |
Schema editor templates |
get_schema_template(template_id) |
Get template with full schema |
Analytics & Pricing
| Method | Description |
|---|---|
get_analytics() |
Usage analytics |
submit_feedback(feedback) |
Submit feedback |
get_pricing(*, billing_cycle) |
Get pricing tiers |
get_current_tier() |
Current subscription & quota |
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
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 oxpdf-0.1.2.tar.gz.
File metadata
- Download URL: oxpdf-0.1.2.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3222b615076867d0a560e7ba7ebd581d84634f00e637fa8e23eb24537951fc9
|
|
| MD5 |
620d9abb41c21ecef86962b93e899da3
|
|
| BLAKE2b-256 |
51f4825a665c8c42b1a566f8e83e8f7bec79253e45c7b6ed6364c529bed8e95f
|
Provenance
The following attestation bundles were made for oxpdf-0.1.2.tar.gz:
Publisher:
publish.yml on risha-max/oxpdf-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oxpdf-0.1.2.tar.gz -
Subject digest:
e3222b615076867d0a560e7ba7ebd581d84634f00e637fa8e23eb24537951fc9 - Sigstore transparency entry: 1076465194
- Sigstore integration time:
-
Permalink:
risha-max/oxpdf-python@2cbd74a5b50316279e2ec92262758a782ba28cfa -
Branch / Tag:
refs/heads/main - Owner: https://github.com/risha-max
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2cbd74a5b50316279e2ec92262758a782ba28cfa -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file oxpdf-0.1.2-py3-none-any.whl.
File metadata
- Download URL: oxpdf-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22041a368cec657fdc0ede100b08dcee275501463b62bae22d611fc177f1c9f5
|
|
| MD5 |
f2bc5b2077eeb83fd026786103d26563
|
|
| BLAKE2b-256 |
7214b8a08259725a4deb04fac253edb2708d6a12a6c8a109b9975a55ab75d2d7
|
Provenance
The following attestation bundles were made for oxpdf-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on risha-max/oxpdf-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oxpdf-0.1.2-py3-none-any.whl -
Subject digest:
22041a368cec657fdc0ede100b08dcee275501463b62bae22d611fc177f1c9f5 - Sigstore transparency entry: 1076465209
- Sigstore integration time:
-
Permalink:
risha-max/oxpdf-python@2cbd74a5b50316279e2ec92262758a782ba28cfa -
Branch / Tag:
refs/heads/main - Owner: https://github.com/risha-max
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2cbd74a5b50316279e2ec92262758a782ba28cfa -
Trigger Event:
workflow_dispatch
-
Statement type: