API Documentation

HTML2PDFAPI is a powerful REST API that converts HTML content and URLs into PDFs, screenshots, and videos using cloud-based Chromium rendering.

PDF Generation

Convert HTML or URLs to high-quality PDF documents with full CSS support

Screenshots

Capture PNG, JPEG, or WebP screenshots of any webpage or HTML content

Video Recording

Record MP4 videos of webpage interactions and animations

Fast & Reliable

Cloud-based Chromium rendering with automatic scaling and high availability

Secure

API key authentication, HTTPS encryption, and optional S3 integration

Cloud Storage

7-day default retention or bring your own S3 bucket for full control

Base URL

https://html2pdfapi.com

Authentication

All API requests require authentication. Include your API key in the request body. Get your API key from your dashboard.

Request Body Parameter
{
  "apiKey": "YOUR_API_KEY",
  "html": "<h1>Hello</h1>",
  "format": "pdf"
}

Keep your API key secure. Never expose it in client-side code or public repositories.

Quick Start

Convert HTML to PDF with a single API call:

curl -X POST https://html2pdfapi.com/api/render \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "YOUR_API_KEY",
    "html": "<h1>Hello World</h1>",
    "format": "pdf"
  }'

Or convert a URL to PDF:

curl -X POST https://html2pdfapi.com/api/render \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "YOUR_API_KEY",
    "url": "https://example.com",
    "format": "pdf",
    "pdf": {
      "format": "A4",
      "printBackground": true
    }
  }'

Input Options

Provide content using one of:

  • html Raw HTML content
  • url URL to capture

Output Formats

Set format to:

pdf png jpeg webp video

Common Use Cases

Full Page Screenshot

Capture a full-page screenshot at a specific viewport size:

curl -X POST https://html2pdfapi.com/api/render \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "YOUR_API_KEY",
    "url": "https://example.com",
    "format": "png",
    "render": {
      "fullPage": true
    },
    "device": {
      "width": 1920,
      "height": 1080
    }
  }'

Popular Options

render.fullPage

Capture the entire scrollable page, not just the viewport

render.waitTime

Wait for a specified time (ms) after page load before capture

device.width/height

Set the viewport dimensions in pixels

pdf.printBackground

Include background colors and images in PDF output

render.block

Block ads, trackers, cookies, and banners during render

API Reference

Complete reference for all API endpoints and parameters.

POST

/api/render

Convert HTML content or a URL to PDF, image, or video.

Required Parameters

apiKey
string required

Your API key for authentication

format
string required

Output format

pdfpngjpegwebpvideo

Input (one required)

html
string

Raw HTML content to render (use html OR url, not both)

url
string

URL of the webpage to capture (use url OR html, not both)

Optional Parameters

headers
object

Custom HTTP headers to send with the request (e.g., cookies, authorization)

async
boolean

Enable async mode for long-running conversions (default: false)

Responses

200 Success - Render job created
{
  "code": 200,
  "message": "Render started successfully",
  "data": {
    "id": "9j0d2plqq49e48l",
    "status": "queue"
  }
}
400 Bad request - Invalid parameters
401 Unauthorized - Invalid or missing API key
421 Too many requests - Rate limit exceeded
500 Internal server error
GET

/api/render/:id

Check the status of an async render job.

Path Parameters

id
string required

The job ID returned from the POST request

Responses

200 Success - Job status retrieved
{
  "code": 200,
  "data": {
    "id": "11xzi8sjr76hu4z",
    "status": "completed",
    "createdAt": "2024-09-30T21:08:23.254Z",
    "s3_url": "https://..."
  }
}
404 Not found - Job ID does not exist

Response Fields

id

Unique job identifier

status

Current job status

queue processing completed failed
createdAt

Job creation timestamp (ISO 8601)

s3_url

Signed URL to download the rendered file (when completed)

Async Mode

For long-running conversions, use async mode to avoid timeouts. The API returns immediately with a job ID that you can poll for completion.

Non-blocking requests
Webhook notifications
# Start async job
curl -X POST https://html2pdfapi.com/api/render \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "YOUR_API_KEY",
    "url": "https://example.com",
    "format": "pdf",
    "async": true
  }'

# Response: { "data": { "id": "job_abc123", "status": "queue" } }

# Check job status
curl -X POST https://html2pdfapi.com/api/render/job_abc123 \
  -H "Content-Type: application/json" \
  -d '{"apiKey": "YOUR_API_KEY"}'

Job Status Values

queue
processing
completed
failed

Business and Enterprise plans can configure webhooks to receive notifications when jobs complete.

Storage

Generated files are stored on our servers and accessible via signed URLs. Configure storage to match your needs.

Default Storage

Files are stored for 7 days on our servers. Access them via the s3_url in the response.

Bring Your Own S3

Configure your own S3 bucket in the dashboard for unlimited retention and full control over your files.

Ready to get started?

Create an account and get your API key to start converting.