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 creditsLoads the page in a browser and prints it. 5 credits.
| Parameter | In | Type | Rules |
|---|---|---|---|
| url * | query | string | max 2048 chars · Page to read. http or https, public hosts only. |
| format | query | string | one of a4, letter, legal · default a4 |
| landscape | query | boolean | default false |
| margin | query | string | default 10mm · One length for all sides: mm, cm, in or px. Max 2 inches. |
| print_background | query | boolean | default true |
| scale | query | number | 0.1 to 2 · default 1 |
| delay_ms | query | integer | 0 to 5000 · default 0 |
| response | query | string | one of binary, json · default binary |
curl 'https://api.apifor.dev/v1/pdf?url=' \
-H 'x-api-key: YOUR_API_KEY'{
"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 credits413HTML body larger than 2 MB422PDF larger than 20 MB502The page or the browser failed (upstream status, too many redirects, DNS)503Browser Rendering is busy or unavailable504The page took longer than 15 seconds
POST
/v1/pdf5 creditsSend 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.
| Parameter | In | Type | Rules |
|---|---|---|---|
| format | query | string | one of a4, letter, legal · default a4 |
| landscape | query | boolean | default false |
| margin | query | string | default 10mm · One length for all sides: mm, cm, in or px. Max 2 inches. |
| print_background | query | boolean | default true |
| scale | query | number | 0.1 to 2 · default 1 |
| delay_ms | query | integer | 0 to 5000 · default 0 |
| response | query | string | one of binary, json · default binary |
{
"html": "<h1>Invoice 1042</h1><p>Total: $120.00</p>",
"format": "letter",
"response": "json"
}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"}'{
"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 credits413HTML body larger than 2 MB422PDF larger than 20 MB502The page or the browser failed (upstream status, too many redirects, DNS)503Browser Rendering is busy or unavailable504The page took longer than 15 seconds