A Python SDK for PDF Craft API
Project description
PDF Craft SDK
A Python SDK for interacting with the PDF Craft API. It simplifies the process of converting PDFs to Markdown or EPUB by handling authentication, task submission, and result polling.
Installation
You can install the package from PyPI:
pip install pdf-craft-sdk
Usage
Basic Usage
The SDK provides a high-level convert method that handles everything for you (submission + polling).
from pdf_craft_sdk import PDFCraftClient, FormatType
# Initialize the client
client = PDFCraftClient(api_key="YOUR_API_KEY")
# Convert a PDF to Markdown and wait for the result
try:
pdf_url = "cache://your-pdf-file.pdf"
download_url = client.convert(pdf_url, format_type=FormatType.MARKDOWN)
print(f"Conversion successful! Download URL: {download_url}")
except Exception as e:
print(f"An error occurred: {e}")
Advanced Usage
If you prefer to handle the steps manually or asynchronously:
from pdf_craft_sdk import PDFCraftClient, FormatType
client = PDFCraftClient(api_key="YOUR_API_KEY")
# 1. Submit task
task_id = client.submit_conversion(
pdf_url="cache://your-pdf-file.pdf",
format_type=FormatType.MARKDOWN
)
print(f"Task submitted. ID: {task_id}")
# 2. Wait for completion explicitly
try:
download_url = client.wait_for_completion(task_id, format_type=FormatType.MARKDOWN)
print(f"Download URL: {download_url}")
except Exception as e:
print(f"Conversion failed or timed out: {e}")
Configuration
max_wait: Maximum time (in seconds) to wait for the conversion. Default is 300.model: The model to use for conversion. Default is "gundam".
# Example with custom timeout and model
download_url = client.convert(
pdf_url="...",
model="gundam",
max_wait=600
)
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 pdf_craft_sdk-0.2.0.tar.gz.
File metadata
- Download URL: pdf_craft_sdk-0.2.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fb93e66cb5c1def9d94049ed0c385021a0185b0aebf44f04b203231d3a79083
|
|
| MD5 |
a7d599c4cc049e31635170f41c9219b2
|
|
| BLAKE2b-256 |
d65b35ac0338e04c4c747d51c357c0f115c83672cae9dd293236c1170387601a
|
File details
Details for the file pdf_craft_sdk-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pdf_craft_sdk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2af3e6ece33f50317d864990092246f6a96eb656e38d896c894a33599049b02
|
|
| MD5 |
764e5b67cee6d0ce8e760af6df24be32
|
|
| BLAKE2b-256 |
b46675b343a0744119d18f3664559acf43f554862802506eab6d45c7e97ded20
|