Generate a PDF from any page. Uploaded to CDN.
Request body
| Field | Type | Description |
|---|
url | string | Required. The URL to process. |
options | object | Optional configuration (see below). |
Options
| Option | Type | Description |
|---|
format | string | Page format: A4, Letter, etc. Default: A4. |
landscape | boolean | Landscape orientation. Default: false. |
printBackground | boolean | Include background graphics. Default: true. |
scale | number | Scale of the page (0.1-2). Default: 1. |
margin | object | Margins: { top, right, bottom, left }. Default: 20px each. |
waitForSelector | string | Wait for a CSS selector before generating. |
waitUntil | string | "networkidle0", "networkidle2", "load", "domcontentloaded". Default: "networkidle0". |
curl -X POST https://crawlapi.dev/api/pdf \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"url":"https://example.com","options":{"format":"A4","landscape":false}}'
{
"success": true,
"data": {
"url": "https://cdn.crawlapi.dev/pdfs/abc123.pdf",
"sourceUrl": "https://example.com",
"format": "A4",
"size": "52.3 KB"
},
"credits_used": 3,
"credits_remaining": 497
}
Error codes
| Status | Meaning |
|---|
400 | Missing or invalid URL / bad options |
401 | Missing or invalid API key |
403 | Insufficient credits |
405 | Wrong HTTP method (use POST) |
429 | Rate limit exceeded (60/min) |
500 | Server error |