API DOCUMENTATION

Getting Started with the Pretty PDF API

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.

API DOCUMENTATION

Prerequisites

What you need before making your first API call.

Before you begin, make sure you have the following:

  • A Pretty PDF account — Sign up at prettypdfprinter.com. The free tier works for exploring the dashboard, but API access requires a paid plan.
  • An active Pro+ or API Scale subscription — API access is available on Pro+ ($9/mo) and API Scale ($29/mo) tiers. You can upgrade from your account settings at any time.
  • An API key — Generate one from your Pretty PDF dashboard under the API Keys section. You will create this in Step 1 below.
  • An HTTP client — cURL, Postman, or any programming language with HTTP support (Python requests, JavaScript fetch, etc.).
API DOCUMENTATION

Step 1: Get your API key

Generate an API key from your dashboard to authenticate every request.

1

Open the dashboard

Log in to your Pretty PDF account and navigate to the API Keys section in your dashboard settings.

2

Generate a new key

Click Generate New Key. Give your key a descriptive name (e.g., "Development", "Production", "CI/CD Pipeline") to help you track usage later.

3

Copy and store securely

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.

4

Manage multiple keys

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.

API DOCUMENTATION

Step 2: Make your first request

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"}'

Understanding the response

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.

API DOCUMENTATION

Step 3: Customize your output

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"
  }'

Key parameters

  • template — Choose from five built-in templates: clean (default), minimal, corporate, academic, or dark. Each template applies different typography, spacing, and color schemes optimized for its use case.
  • page_size — Set the output page dimensions: A4 (210 x 297 mm), Letter (8.5 x 11 in), or Legal (8.5 x 14 in).
  • capture_mode — Control content extraction: article extracts the main content and removes clutter, full keeps the complete page, selection renders only the provided HTML fragment without extraction.
  • orientation — Set page orientation: 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.

API DOCUMENTATION

Authentication and rate limits

How authentication works and the throughput boundaries for each tier.

API key authentication

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 by tier

Rate limits are applied per minute on a rolling window. Monthly PDF quotas are tracked separately and reset on your billing cycle date.

  • Pro+ — 10 requests per minute, 100 PDFs per month. Suitable for individual developers, personal automation, and low-volume integrations.
  • API Scale — 30 requests per minute, 500 PDFs per month. Designed for teams running scheduled pipelines, CI/CD integrations, and multi-user applications.

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.

API DOCUMENTATION

Error handling

Common error codes and best practices for handling failures gracefully.

Common error codes

  • 400 Bad Request — The request body is invalid or missing required fields. Check that your JSON is well-formed and includes either html or url.
  • 401 Unauthorized — The API key is missing, invalid, or has been revoked. Verify that the X-API-Key header is present and the key is active in your dashboard.
  • 429 Too Many Requests — You have exceeded your rate limit. Read the Retry-After header and wait before sending the next request.
  • 500 Internal Server Error — An unexpected error occurred on the server. Retry the request after a short delay. If the error persists, contact support.

Example error response

{
  "error": "rate_limit_exceeded",
  "message": "You have exceeded your rate limit of 10 requests per minute.",
  "retry_after": 12
}

Best practice: exponential backoff

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.

API DOCUMENTATION

Code examples

Ready-to-use examples in Python and JavaScript for generating a PDF from a URL.

Python

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)

JavaScript

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

Frequently asked questions about the Pretty PDF API

API access is available on Pro+ ($9/mo) and API Scale ($29/mo) tiers. The free tier includes the Chrome extension but not API access.
Send requests sequentially with appropriate delays to stay within rate limits. For high-volume needs, the API Scale tier offers 30 requests per minute. See our Python automation guide for batch processing patterns.
Yes. Use the /v1/generate endpoint with an html parameter containing your HTML content. This is useful when you have already fetched or generated the content yourself.
The API returns a JSON response with a document ID and download URL. Use the download URL to retrieve the generated PDF file.
The API is served from a single server location. Response times may vary by region. The API itself is accessible from anywhere with internet access.

Start generating PDFs with the API today

From API key to your first PDF in under five minutes. No browser automation, no headless Chrome, no maintenance overhead.

Get API Key