API Documentation

Base URL: https://pdf.grabshot.dev

Authentication

All API requests require an API key. Pass it as a header:

X-API-Key: pdf_your_key_here

Or as a query parameter: ?api_key=pdf_your_key_here

POST /v1/pdf/html

Convert HTML to PDF.

curl -X POST https://pdf.grabshot.dev/v1/pdf/html \
  -H "Content-Type: application/json" \
  -H "X-API-Key: pdf_your_key" \
  -d '{
    "html": "<h1>Hello World</h1><p>My first PDF</p>",
    "options": {
      "format": "A4",
      "landscape": false,
      "margin": { "top": "20mm", "bottom": "20mm", "left": "15mm", "right": "15mm" },
      "printBackground": true,
      "filename": "my-document.pdf"
    }
  }' --output document.pdf

Options

ParameterTypeDefaultDescription
formatstringA4Page size: A4, Letter, Legal, Tabloid, A3, A5
landscapebooleanfalseLandscape orientation
marginobject20mm/15mmPage margins: { top, bottom, left, right }
printBackgroundbooleantruePrint background colors/images
widthstringCustom width (e.g. "210mm"). Overrides format.
heightstringCustom height. Overrides format.
headerTemplatestringHTML for page header (paid plans)
footerTemplatestringHTML for page footer (paid plans)
filenamestringdocument.pdfFilename in Content-Disposition header

POST /v1/pdf/url

Convert a URL to PDF. We render the page in a real browser.

curl -X POST https://pdf.grabshot.dev/v1/pdf/url \
  -H "Content-Type: application/json" \
  -H "X-API-Key: pdf_your_key" \
  -d '{
    "url": "https://example.com",
    "options": {
      "format": "A4",
      "delay": 2000,
      "viewport": { "width": 1280, "height": 800 }
    }
  }' --output page.pdf

Additional options: delay (ms, max 5000) — wait before generating. viewport — set browser viewport size. waitUntil — networkidle0 or networkidle2 (default).

GET /v1/pdf

Quick URL-to-PDF via query params.

curl "https://pdf.grabshot.dev/v1/pdf?api_key=pdf_your_key&url=https://example.com&format=A4" --output page.pdf

Account & Usage

# Register
curl -X POST https://pdf.grabshot.dev/v1/users/register \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "password": "your_password"}'

# Check usage
curl https://pdf.grabshot.dev/v1/users/me \
  -H "X-API-Key: pdf_your_key"

Response Headers

X-Duration-Ms — Time to generate the PDF (ms)

X-Usage-Remaining — Remaining monthly quota

X-RateLimit-Limit — Requests per minute allowed

X-RateLimit-Remaining — Requests left in current window

Error Codes

CodeMeaning
400Bad request (missing html/url, invalid params)
401Invalid or missing API key
429Rate limit or monthly quota exceeded
500PDF generation failed