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"
Examples
See runnable examples in the SDK repo: examples/python (basic_rename.py, pdf_split.py).
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 boundariespages- Split every N pagesblank- 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
Use the synchronous methods for simple scripts/CLIs. Use the async methods when you're already in an async app (FastAPI, etc.) or want concurrency.
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,
# Optional: Enable debug logging (default: False)
debug=True,
# Optional: Custom logger (default: stderr logger when debug=True)
logger=my_logger,
)
Debug Logging
Enable debug logging to see HTTP request details for troubleshooting:
client = RenamedClient(api_key="rt_...", debug=True)
# Output:
# [Renamed] POST /rename -> 200 (234ms)
# [Renamed] Upload: document.pdf (1.2 MB)
Use Python's standard logging module for custom logging:
import logging
# Configure logging level
logging.basicConfig(level=logging.DEBUG)
# Or use a custom logger
logger = logging.getLogger("my_app")
client = RenamedClient(api_key="rt_...", logger=logger)
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
Release history Release notifications | RSS feed
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 renamed-0.1.0b4.tar.gz.
File metadata
- Download URL: renamed-0.1.0b4.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc798e7b5d4bad1fd647169f6424339048189b2a899dc25076e9d2256f477ba2
|
|
| MD5 |
daf72f018003890a9d0e70a550c0c10e
|
|
| BLAKE2b-256 |
763591a33bed77a832756ac5824f131c877b96a587889590845f54c3d615ec19
|
Provenance
The following attestation bundles were made for renamed-0.1.0b4.tar.gz:
Publisher:
release.yml on renamed-to/renamed-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
renamed-0.1.0b4.tar.gz -
Subject digest:
dc798e7b5d4bad1fd647169f6424339048189b2a899dc25076e9d2256f477ba2 - Sigstore transparency entry: 813615687
- Sigstore integration time:
-
Permalink:
renamed-to/renamed-sdk@5fd5f4c5db4adda6f7fee6c63676950857b7a4ce -
Branch / Tag:
refs/tags/v0.1.0-beta.4 - Owner: https://github.com/renamed-to
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5fd5f4c5db4adda6f7fee6c63676950857b7a4ce -
Trigger Event:
push
-
Statement type:
File details
Details for the file renamed-0.1.0b4-py3-none-any.whl.
File metadata
- Download URL: renamed-0.1.0b4-py3-none-any.whl
- Upload date:
- Size: 11.6 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 |
79534018a254bcacfc90f86ac295f0049fea26dbfec0237729a6030e909a867a
|
|
| MD5 |
0b64fa59c9cf2fb1eae17a66292c6682
|
|
| BLAKE2b-256 |
62cd0e09ddfe378b4487c8dd21665dc648487207ec5f1002bdff4b690e721d6f
|
Provenance
The following attestation bundles were made for renamed-0.1.0b4-py3-none-any.whl:
Publisher:
release.yml on renamed-to/renamed-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
renamed-0.1.0b4-py3-none-any.whl -
Subject digest:
79534018a254bcacfc90f86ac295f0049fea26dbfec0237729a6030e909a867a - Sigstore transparency entry: 813615692
- Sigstore integration time:
-
Permalink:
renamed-to/renamed-sdk@5fd5f4c5db4adda6f7fee6c63676950857b7a4ce -
Branch / Tag:
refs/tags/v0.1.0-beta.4 - Owner: https://github.com/renamed-to
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5fd5f4c5db4adda6f7fee6c63676950857b7a4ce -
Trigger Event:
push
-
Statement type: