From API key to your first PDF in under five minutes. This quickstart walks you through authentication, your first request, and the key parameters that control your output.
What you need before making your first API call.
Before you begin, make sure you have the following:
Generate an API key from your dashboard to authenticate every request.
Log in to your Pretty PDF account and navigate to the API Keys section in your dashboard settings.
Click Generate New Key. Give your key a descriptive name (e.g., "Development", "Production", "CI/CD Pipeline") to help you track usage later.
Copy the key immediately — it is only shown once. Store it in an environment variable or secrets manager. Treat it like a password. Never commit API keys to version control.
You can create multiple keys — one per application or environment — and revoke them individually. Revoking a key does not affect your other keys or your account.
One cURL command to generate a PDF from any URL.
The simplest way to generate a PDF is to send a URL to the /v1/generate/url endpoint. The server fetches the page, extracts the main content, applies a template, and returns the result.
curl -X POST https://api.prettypdfprinter.com/v1/generate/url \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/article"}'
The API returns a JSON response containing the document ID and a download URL for the generated PDF:
{
"document_id": "doc_abc123",
"download_url": "https://api.prettypdfprinter.com/v1/files/doc_abc123",
"title": "Example Article",
"pages": 3,
"file_size": 245760,
"template": "clean",
"created_at": "2026-02-13T10:30:00Z"
}
Use the download_url to retrieve the PDF file. The download URL is authenticated — include your API key in the request header when fetching the file.
Control templates, page size, and content extraction with request parameters.
Send HTML directly with parameters to control the output style and layout:
curl -X POST https://api.prettypdfprinter.com/v1/generate \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"html": "<article>Your content here</article>",
"template": "corporate",
"page_size": "A4",
"capture_mode": "article"
}'
clean (default), minimal, corporate, academic, or dark. Each template applies different typography, spacing, and color schemes optimized for its use case.A4 (210 x 297 mm), Letter (8.5 x 11 in), or Legal (8.5 x 14 in).article extracts the main content and removes clutter, full keeps the complete page, selection renders only the provided HTML fragment without extraction.portrait (default) or landscape. Landscape is useful for wide tables and data-heavy content.Every parameter has a sensible default, so you can start with a simple request and add parameters as your needs evolve.
How authentication works and the throughput boundaries for each tier.
Every request must include your API key in the X-API-Key header. Without a valid key, the API returns an HTTP 401 response. Keys are scoped to your account and inherit the rate limits of your subscription tier.
Rate limits are applied per minute on a rolling window. Monthly PDF quotas are tracked separately and reset on your billing cycle date.
When you exceed your limit, the API returns an HTTP 429 (Too Many Requests) response with a Retry-After header indicating how many seconds to wait before your next request.
Common error codes and best practices for handling failures gracefully.
html or url.X-API-Key header is present and the key is active in your dashboard.Retry-After header and wait before sending the next request.{
"error": "rate_limit_exceeded",
"message": "You have exceeded your rate limit of 10 requests per minute.",
"retry_after": 12
}
Implement exponential backoff for rate limit errors. Start with a 1-second delay, then double the wait time on each consecutive 429 response up to a maximum of 60 seconds. This avoids overwhelming the API with retries and allows your request queue to drain naturally as capacity becomes available.
Ready-to-use examples in Python and JavaScript for generating a PDF from a URL.
import requests
API_KEY = "your_api_key_here"
API_URL = "https://api.prettypdfprinter.com/v1/generate/url"
response = requests.post(
API_URL,
headers={
"X-API-Key": API_KEY,
"Content-Type": "application/json",
},
json={
"url": "https://example.com/article",
"template": "clean",
"page_size": "A4",
},
)
data = response.json()
print(f"PDF ready: {data['download_url']}")
# Download the PDF file
pdf_response = requests.get(
data["download_url"],
headers={"X-API-Key": API_KEY},
)
with open("output.pdf", "wb") as f:
f.write(pdf_response.content)
const API_KEY = "your_api_key_here";
const API_URL = "https://api.prettypdfprinter.com/v1/generate/url";
const response = await fetch(API_URL, {
method: "POST",
headers: {
"X-API-Key": API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://example.com/article",
template: "clean",
page_size: "A4",
}),
});
const data = await response.json();
console.log(`PDF ready: ${data.download_url}`);
// Download the PDF file
const pdfResponse = await fetch(data.download_url, {
headers: { "X-API-Key": API_KEY },
});
const pdfBuffer = await pdfResponse.arrayBuffer();
// Save or process the PDF buffer as needed
From API key to your first PDF in under five minutes. No browser automation, no headless Chrome, no maintenance overhead.
Get API Key