HTML to PDF API for any URL

Any URL to a print-ready PDF. Rendered through a real browser behind residential proxies.

POST /v1/scrape/pdf 25 / 35 credits Utilities

Point us at a URL and get back a base64-encoded PDF rendered through a real headless browser behind residential proxies. Pick the paper size, portrait or landscape, and the viewport. We handle the browser and the proxy so you never run or babysit one yourself.

The hard part

A faithful PDF in production means running a headless browser, waiting for the page to actually settle, clearing anti-bot walls, and picking the right paper geometry — then keeping that browser fleet alive. You send a URL and a paper size; we return the bytes.

PDF API: what you get

  • Paper sizes: Letter, Legal, Tabloid, Ledger, and A0–A6. landscape=true for wide content.
  • viewport_width/viewport_height control page layout before pagination.
  • cookies and headers render authenticated or gated pages; session_id reuses a sticky residential exit IP for multi-step flows.
  • wait_extra_ms waits out late-loading SPA content before capture.
  • Base64 returned inline (no S3 round-trip, no presigned-URL dance).
  • Failures and timeouts don't bill.

PDF API use cases

  • Archive articles and pages

    Save a print-ready copy of a page as it looked on the day you captured it.

  • Invoices and receipts

    Render a logged-in receipt or invoice page to PDF by sending its cookies.

  • Reports from web dashboards

    Turn a web report into a landscape PDF so wide tables fit the page.

PDF API quickstart: Python, Node and curl

Install the SDK with pip install scrapenest (PyPI) or npm install scrapenest (npm), or send the raw HTTP call with your key in the Authorization: Bearer header. No key yet? Sign up free, verify your email, then create a key in your dashboard.

import os
from scrapenest import Client

client = Client(os.environ["SCRAPENEST_API_KEY"], timeout=120)
doc = client.pdf("https://stripe.com/docs/api", format="A4")
doc.save("page.pdf")
print(doc.bytes, "bytes,", doc.format, doc.credits_charged, "credits")

PDF API request and response

Request body

{
  "url": "https://stripe.com/docs/api",
  "format": "A4"
}

Response JSON

{
  "url": "https://stripe.com/docs/api",
  "final_url": "https://stripe.com/docs/api",
  "status_code": 200,
  "proxy_used": "residential",
  "elapsed_ms": 4120,
  "format": "A4",
  "landscape": false,
  "bytes": 248913,
  "pdf_base64": "JVBERi0xLjcKJ…",
  "cache_hit": false,
  "credits_charged": 25
}

Fields with no value are left out of the JSON rather than sent as null, so read optional fields defensively. proxy_used is the exception: it is always present, null included.

PDF API pricing

25 credits for a standard render; 35 credits for landscape or large paper (Tabloid, Ledger, A0–A2). Cache hits bill at 1 credit. Failures don't bill.

  • Large or landscape formats (Tabloid, Ledger, A0–A2) bill at 35 credits; standard portrait sizes bill at 25.
  • A render that takes longer than 20 seconds streams keepalive bytes so the connection stays open. One render gets 75 seconds across every tier; past that it fails with pdf_failed and nothing is billed.

Plans and pay-as-you-go rates are on the pricing page.

PDF API limits

  • Paper: Letter (default), Legal, Tabloid, Ledger and A0 to A6. landscape must be a JSON boolean.
  • Viewport: 320 to 3840 by 240 to 2160, default 1280 × 720. wait_extra_ms: up to 10,000.
  • One render gets 75 seconds across every tier. Past 20 seconds the response streams, so a later error arrives inside the 200 body.
  • Caching is off unless you set cache_ttl_seconds. Requests with cookies, headers or session_id are never cached.

PDF API error codes

HTTPCodeMeaning
422target_errorThe target returned an error status, or its host doesn't resolve in DNS.
503pdf_failedThe render failed or ran past 75 seconds. Not billed.
503connection_failedThe DNS lookup failed temporarily. Retry with backoff.
400unsafe_urlThe URL is malformed or points at a private host.
400redirect_to_unsafe_urlThe page redirected to a private address.

Every endpoint can also return 401 unauthorized (missing or wrong key), 402 insufficient_credits (balance used up), 403 email_not_verified (an email signup must verify its address before its key works) and 429 rate_limited or concurrency_limit_exceeded. All errors share one JSON envelope; see the error reference.

questions

PDF API FAQ

Which paper sizes are supported?

Letter (the default), Legal, Tabloid, Ledger and A0 through A6, in portrait or with landscape: true.

What does a PDF cost?

25 credits for a standard size in portrait, and 35 for landscape or the large sizes (Tabloid, Ledger, A0 to A2). A cache hit bills 1, and failed renders bill nothing.

Can I render a page behind a login?

Yes. Pass cookies and headers, and reuse a session_id to keep the same exit IP across calls.

How do I save the file?

The PDF comes back base64-encoded in pdf_base64. Decode it and write the bytes; in the Python SDK the response has a save(path) helper.

Page updated