PDF All docs

PDF API Reference

2 routes. Base URL https://api.apifor.dev, authenticated with x-api-key. Failed calls are not charged. Overview, limits and sources are on the HTML to PDF API page.

GET/v1/pdf5 credits

Loads the page in a browser and prints it. 5 credits.

ParameterInTypeRules
url *querystringmax 2048 chars · Page to read. http or https, public hosts only.
formatquerystringone of a4, letter, legal · default a4
landscapequerybooleandefault false
marginquerystringdefault 10mm · One length for all sides: mm, cm, in or px. Max 2 inches.
print_backgroundquerybooleandefault true
scalequerynumber0.1 to 2 · default 1
delay_msqueryinteger0 to 5000 · default 0
responsequerystringone of binary, json · default binary
GET/v1/pdf
curl 'https://api.apifor.dev/v1/pdf?url=' \
  -H 'x-api-key: YOUR_API_KEY'
Example response · 200
{
  "success": true,
  "data": {
    "source": "url",
    "url": "https://en.wikipedia.org/wiki/Tide_table",
    "final_url": "https://en.wikipedia.org/wiki/Tide_table",
    "format": "a4",
    "landscape": false,
    "bytes": 241877,
    "pdf_base64": "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9U...",
    "created_at": "2026-11-28T15:52:03.118Z"
  }
}
  • 200The PDF, or JSON with base64 when response=json (pdf_base64 shortened here).
  • 400Invalid parameters or a blocked URL (private address, bad scheme or port)
  • 402Not enough credits
  • 413HTML body larger than 2 MB
  • 422PDF larger than 20 MB
  • 502The page or the browser failed (upstream status, too many redirects, DNS)
  • 503Browser Rendering is busy or unavailable
  • 504The page took longer than 15 seconds
POST/v1/pdf5 credits

Send raw HTML (text/html) or JSON with html or url. Options can go in the query or the JSON body. Images and styles your HTML links to must be on public hosts. 5 credits.

ParameterInTypeRules
formatquerystringone of a4, letter, legal · default a4
landscapequerybooleandefault false
marginquerystringdefault 10mm · One length for all sides: mm, cm, in or px. Max 2 inches.
print_backgroundquerybooleandefault true
scalequerynumber0.1 to 2 · default 1
delay_msqueryinteger0 to 5000 · default 0
responsequerystringone of binary, json · default binary
Request body · application/json
{
  "html": "<h1>Invoice 1042</h1><p>Total: $120.00</p>",
  "format": "letter",
  "response": "json"
}
POST/v1/pdf
curl -X POST 'https://api.apifor.dev/v1/pdf' \
  -H 'content-type: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{"html":"<h1>Invoice 1042</h1><p>Total: $120.00</p>","format":"letter","response":"json"}'
Example response · 200
{
  "success": true,
  "data": {
    "source": "html",
    "url": null,
    "final_url": null,
    "format": "letter",
    "landscape": false,
    "bytes": 18420,
    "pdf_base64": "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9U...",
    "created_at": "2026-11-28T15:53:40.902Z"
  }
}
  • 200The PDF, or JSON with base64 when response=json (pdf_base64 shortened here).
  • 400Invalid parameters or a blocked URL (private address, bad scheme or port)
  • 402Not enough credits
  • 413HTML body larger than 2 MB
  • 422PDF larger than 20 MB
  • 502The page or the browser failed (upstream status, too many redirects, DNS)
  • 503Browser Rendering is busy or unavailable
  • 504The page took longer than 15 seconds

Error handling · Rate limits · Prices