TemplateFox Python SDK
Official Python SDK for TemplateFox - Generate PDFs from HTML templates via API.
Installation
pip install templatefox
Or with poetry:
poetry add templatefox
Quick Start
from templatefox import ApiClient, Configuration
from templatefox.api import PDFApi
from templatefox.models import CreatePdfRequest
# Initialize the client
config = Configuration()
config.api_key['ApiKeyAuth'] = 'your-api-key'
with ApiClient(config) as client:
api = PDFApi(client)
# Generate a PDF
response = api.create_pdf(
CreatePdfRequest(
template_id='YOUR_TEMPLATE_ID',
data={
'name': 'John Doe',
'invoice_number': 'INV-001',
'total_amount': 150.00,
}
)
)
print(f'PDF URL: {response.url}')
print(f'Credits remaining: {response.credits_remaining}')
Features
- Template-based PDF generation - Create templates with dynamic variables, generate PDFs with your data
- Multiple export options - Get a signed URL (default) or raw binary PDF
- S3 integration - Upload generated PDFs directly to your own S3-compatible storage
- Type hints - Full type annotations for IDE support
API Methods
PDF Generation
from templatefox.models import CreatePdfRequest
# Generate PDF and get URL
response = api.create_pdf(
CreatePdfRequest(
template_id='TEMPLATE_ID',
data={'name': 'John Doe'},
export_type='url', # 'url' or 'binary'
expiration=86400, # URL expiration in seconds (default: 24h)
filename='invoice-001' # Custom filename
)
)
Templates
from templatefox.api import TemplatesApi
templates_api = TemplatesApi(client)
# List all templates
templates = templates_api.list_templates()
for template in templates.templates:
print(f'{template.id}: {template.name}')
# Get template fields
fields = templates_api.get_template_fields(template_id='TEMPLATE_ID')
for field in fields:
print(f'{field.key}: {field.type} (required: {field.required})')
Account
from templatefox.api import AccountApi
account_api = AccountApi(client)
# Get account info
account = account_api.get_account()
print(f'Credits: {account.credits}')
print(f'Email: {account.email}')
# List transactions
transactions = account_api.list_transactions(limit=100, offset=0)
for tx in transactions.transactions:
print(f'{tx.transaction_type}: {tx.credits} credits')
S3 Integration
from templatefox.api import IntegrationsApi
from templatefox.models import S3ConfigRequest
integrations_api = IntegrationsApi(client)
# Save S3 configuration
integrations_api.save_s3_config(
S3ConfigRequest(
endpoint_url='https://s3.amazonaws.com',
access_key_id='AKIAIOSFODNN7EXAMPLE',
secret_access_key='your-secret-key',
bucket_name='my-pdf-bucket',
default_prefix='generated/pdfs/'
)
)
# Test connection
test = integrations_api.test_s3_connection()
print(f'Connection: {"OK" if test.success else "Failed"}')
Configuration
from templatefox import Configuration
config = Configuration(
host='https://api.templatefox.com', # Default API URL
)
config.api_key['ApiKeyAuth'] = 'your-api-key'
# Or use environment variable
import os
config.api_key['ApiKeyAuth'] = os.environ.get('TEMPLATEFOX_API_KEY')
Error Handling
from templatefox.exceptions import ApiException
try:
response = api.create_pdf(CreatePdfRequest(...))
except ApiException as e:
if e.status == 402:
print('Insufficient credits')
elif e.status == 403:
print('Access denied - check your API key')
elif e.status == 404:
print('Template not found')
else:
print(f'Error: {e.reason}')
Async Support
import asyncio
from templatefox import ApiClient, Configuration
from templatefox.api import PDFApi
from templatefox.models import CreatePdfRequest
async def generate_pdfs():
config = Configuration()
config.api_key['ApiKeyAuth'] = 'your-api-key'
async with ApiClient(config) as client:
api = PDFApi(client)
# Use async methods
response = await api.create_pdf(
CreatePdfRequest(template_id='...', data={...})
)
asyncio.run(generate_pdfs())
Documentation
Support
- Email: support@templatefox.com
- Issues: GitHub Issues
License
MIT License - see LICENSE for details.
Metadata
Release files for templatefox 1.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| templatefox-1.13.0.tar.gz | 61.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| templatefox-1.13.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 180.5 kB
Release files / templatefox-1.13.0.tar.gz
| Download URL | templatefox-1.13.0.tar.gz |
|---|---|
| Size | 61.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e00a4dd7b45eecc4a4f50d2eee70465d367aeae9798e5573ec99491a5d10842
|
|
BLAKE2b-256 checksum How to use checksums |
464d2caccb52ee7c8e7e6f1550957665a390d0338e34dae356d133cdb94fe45e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.
Transparency logRelease files / templatefox-1.13.0-py3-none-any.whl
| Download URL | templatefox-1.13.0-py3-none-any.whl |
|---|---|
| Size | 118.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4f88deb6bbafa8f6268b4b3e3d655608471dc3a309b1f3fd59ae315072da717
|
|
BLAKE2b-256 checksum How to use checksums |
86a90ad37c1a35230b03ffbc12f327df8462cd0e854e4c0651ae5010838f821f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.
Transparency log