Developer quickstart
Generate PDFs in Python
Use Requests to post JSON data, handle API errors, and write the binary PDF response.
Prerequisites
- A PDFDesignAPI account and API token.
- A template UUID with a schema and at least one data binding.
- Trusted server-side code where the token remains secret.
Install the HTTP client
python -m pip install requestsGenerate and save the PDF
import os
import requests
response = requests.post(
f"https://pdfdesignapi.com/api/v1/generate/single/{os.environ['TEMPLATE_UUID']}",
headers={"Authorization": f"Bearer {os.environ['PDFDESIGNAPI_TOKEN']}"},
json={"data": {"customer": {"name": "Example BV"}}},
timeout=60,
)
response.raise_for_status()
with open("document.pdf", "wb") as pdf:
pdf.write(response.content)Production notes
- Always configure a timeout.
- Catch requests.HTTPError where the application can report or retry failures.
- Do not retry schema validation errors without changing the request.