Skip to main content

Official Python SDK for renamed.to API

Project description

renamed

Official Python SDK for the renamed.to API.

Installation

pip install renamed
# or
poetry add renamed
# or
uv add renamed

Quick Start

from renamed import RenamedClient

client = RenamedClient(api_key="rt_your_api_key_here")

# Rename a file using AI
result = client.rename("invoice.pdf")
print(result.suggested_filename)
# => "2025-01-15_AcmeCorp_INV-12345.pdf"

Usage

Rename Files

Rename files using AI-powered content analysis:

from renamed import RenamedClient

client = RenamedClient(api_key="rt_...")

# From file path
result = client.rename("/path/to/document.pdf")

# From bytes
with open("document.pdf", "rb") as f:
    result = client.rename(f.read())

# With custom template
result = client.rename("invoice.pdf", template="{date}_{vendor}_{type}")

print(result.suggested_filename)  # "2025-01-15_AcmeCorp_Invoice.pdf"
print(result.folder_path)         # "2025/AcmeCorp/Invoices"
print(result.confidence)          # 0.95

Split PDFs

Split multi-page PDFs into individual documents:

from pathlib import Path

# Start the split job
job = client.pdf_split("multi-page.pdf", mode="auto")

# Wait for completion with progress updates
result = job.wait(lambda status: print(f"Progress: {status.progress}%"))

# Download the split documents
for doc in result.documents:
    content = client.download_file(doc.download_url)
    Path(doc.filename).write_bytes(content)

Split modes:

  • auto - AI detects document boundaries
  • pages - Split every N pages
  • blank - Split at blank pages

Extract Data

Extract structured data from documents:

result = client.extract(
    "invoice.pdf",
    prompt="Extract invoice number, date, vendor name, and total amount"
)

print(result.data)
# {
#     "invoiceNumber": "INV-12345",
#     "date": "2025-01-15",
#     "vendor": "Acme Corp",
#     "total": 1234.56
# }

Check Credits

user = client.get_user()
print(f"Credits remaining: {user.credits}")

Async Support

All methods have async versions with the _async suffix:

import asyncio
from renamed import RenamedClient

async def main():
    client = RenamedClient(api_key="rt_...")

    # Async rename
    result = await client.rename_async("invoice.pdf")
    print(result.suggested_filename)

    # Async PDF split
    job = await client.pdf_split_async("multi-page.pdf", mode="auto")
    result = await job.wait_async()

    await client.aclose()

asyncio.run(main())

Or use as a context manager:

async with RenamedClient(api_key="rt_...") as client:
    result = await client.rename_async("invoice.pdf")

Configuration

client = RenamedClient(
    # Required: Your API key (get one at https://www.renamed.to/settings)
    api_key="rt_...",

    # Optional: Custom base URL (default: https://www.renamed.to/api/v1)
    base_url="https://www.renamed.to/api/v1",

    # Optional: Request timeout in seconds (default: 30.0)
    timeout=30.0,

    # Optional: Max retries for failed requests (default: 2)
    max_retries=2,
)

Error Handling

from renamed import (
    RenamedClient,
    AuthenticationError,
    RateLimitError,
    InsufficientCreditsError,
    ValidationError,
)

try:
    result = client.rename("document.pdf")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except InsufficientCreditsError:
    print("Not enough credits")
except ValidationError as e:
    print(f"Invalid request: {e.message}")

File Input Types

The SDK accepts multiple file input types:

from pathlib import Path

# File path (str)
client.rename("/path/to/file.pdf")

# Path object
client.rename(Path("file.pdf"))

# Bytes
content = Path("file.pdf").read_bytes()
client.rename(content)

# File-like object
with open("file.pdf", "rb") as f:
    client.rename(f)

Supported File Types

  • PDF (.pdf)
  • Images: JPEG (.jpg, .jpeg), PNG (.png), TIFF (.tiff, .tif)

Requirements

  • Python 3.9+
  • Dependencies: httpx, pydantic

License

MIT

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

renamed-0.1.0b2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

renamed-0.1.0b2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file renamed-0.1.0b2.tar.gz.

File metadata

  • Download URL: renamed-0.1.0b2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for renamed-0.1.0b2.tar.gz
Algorithm Hash digest
SHA256 ab40f96149fdc98ffa745b4f4243ed2342e3c7645d60a41b81cffd61fc10863d
MD5 64219cb79fa422351604879b7578766c
BLAKE2b-256 03d0ea876ec54a4634eb6f37f9fcb22dbad0bf81c3b1976a76fbab008fdfea6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for renamed-0.1.0b2.tar.gz:

Publisher: release.yml on renamed-to/renamed-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file renamed-0.1.0b2-py3-none-any.whl.

File metadata

  • Download URL: renamed-0.1.0b2-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for renamed-0.1.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a1e08b7061eca8f881a5b6d9cc4385721cf3af4abe9c72f23afb841c09ff670
MD5 0503b74979dc06ea6e9220c20082e1e9
BLAKE2b-256 66d3e308b55df4299c612ef7a1dfe0488c07098b1a5ef96d62c76b3f5bb0cece

See more details on using hashes here.

Provenance

The following attestation bundles were made for renamed-0.1.0b2-py3-none-any.whl:

Publisher: release.yml on renamed-to/renamed-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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