Skip to main content

Official Python SDK for Structurify document extraction API

Project description

Structurify Python SDK

Official Python SDK for the Structurify document extraction API.

Installation

pip install structurify

For async support:

pip install structurify[async]

Quick Start

from structurify import Structurify

client = Structurify(api_key="sk_live_your_api_key")

# List available project templates
templates = client.templates.list()

# Create a project from template
project = client.projects.create(
    name="Q1 Invoices",
    template_id="tpl_invoice"
)

# Upload a document
doc = client.documents.upload(
    project_id=project["id"],
    file_path="invoice.pdf"
)

# Run extraction
job = client.extraction.run(project_id=project["id"])

# Wait for completion
completed = client.extraction.wait_for_completion(job["id"])
print(f"Extracted {completed['completedTasks']} cells")

# Export results
export = client.exports.create(project_id=project["id"], format="csv")

API Reference

Client

client = Structurify(
    api_key="sk_live_xxx",     # Required
    base_url="...",            # Optional custom base URL
    timeout=30,                # Request timeout in seconds
    max_retries=3,             # Retry count for failed requests
)

Templates

# List project templates
templates = client.templates.list()

# List column templates
columns = client.templates.list_columns()

# Get specific template
template = client.templates.get("tpl_invoice")

Projects

# List projects
projects = client.projects.list()

# Create project (must use template)
project = client.projects.create(
    name="My Project",
    template_id="tpl_invoice"
)

# Get project with columns and documents
project = client.projects.get("proj_xxx")

# Delete project
client.projects.delete("proj_xxx")

Documents

# Upload from file path
doc = client.documents.upload(
    project_id="proj_xxx",
    file_path="invoice.pdf"
)

# Upload from bytes
doc = client.documents.upload(
    project_id="proj_xxx",
    file_bytes=pdf_bytes,
    name="invoice.pdf"
)

# Get document metadata
doc = client.documents.get("doc_xxx")

# Download document content
content = client.documents.download("doc_xxx")

# Delete document
client.documents.delete("doc_xxx")

Extraction

# Run extraction (consumes credits)
job = client.extraction.run(project_id="proj_xxx")

# Check status
job = client.extraction.get(job["id"])

# Wait for completion
completed = client.extraction.wait_for_completion(
    job["id"],
    timeout=300,        # seconds
    poll_interval=2.0   # seconds
)

# Cancel job
client.extraction.cancel(job["id"])

Exports

# Create export
export = client.exports.create(
    project_id="proj_xxx",
    format="csv"  # or "json"
)

# Download export
data = client.exports.download(export["export"]["id"])

# Save to file
with open("export.csv", "w") as f:
    f.write(data)

Webhooks

from structurify.webhooks import verify_signature

# Verify webhook signature
is_valid = verify_signature(
    payload=request.body,
    signature=request.headers["X-Structurify-Signature"],
    secret="your_webhook_secret"
)

Error Handling

from structurify import (
    Structurify,
    AuthenticationError,
    InsufficientCreditsError,
    NotFoundError,
    RateLimitError,
    ValidationError,
)

client = Structurify(api_key="sk_live_xxx")

try:
    project = client.projects.get("proj_xxx")
except AuthenticationError:
    print("Invalid API key")
except NotFoundError:
    print("Project not found")
except InsufficientCreditsError as e:
    print(f"Not enough credits: {e.message}")
except RateLimitError as e:
    print(f"Rate limited. Retry after: {e.retry_after}s")
except ValidationError as e:
    print(f"Invalid request: {e.message}")

License

MIT License - Copyright (c) 2026 REDSCVRY TECHNOLOGY PRIVATE LIMITED

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

structurify-1.0.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

structurify-1.0.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file structurify-1.0.0.tar.gz.

File metadata

  • Download URL: structurify-1.0.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for structurify-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2e3747e55ce8a73fe497db8b15b45d02d705f20ca11c9c8182de3fa0f51d7302
MD5 413a70dde70027cca134bc7b3ec8a85b
BLAKE2b-256 9f20ed1a5e5c64a5e7603a55da11b871670db6cf1241127ac25de3b0111d4ad0

See more details on using hashes here.

File details

Details for the file structurify-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: structurify-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for structurify-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 518b895abfb098e170b67b3d92797fd5c61205646cd497734d00d5e097681f33
MD5 dccf8934687cf871dadd483bce001672
BLAKE2b-256 bf3fc764d99129a9951e700d8f946aac41b9f3e35f6dfd07512761f646dd0b0d

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