Guides · Python · requests
Take a full-page screenshot in Python with requests
"full_page": true captures the whole document, not just the viewport — the render scrolls the page, waits for lazy-loaded images along the way, and returns one tall image. width sets the viewport width the page lays itself out at; height is measured, not guessed.
Below is a complete, runnable Python program using requests (pip install requests). It reads your API key from the SNAPDOK_KEY environment variable — free keys take about thirty seconds and need no card.
import os
import requests
resp = requests.post(
"https://snapdok.io/v1/render",
headers={"Authorization": "Bearer " + os.environ["SNAPDOK_KEY"]},
json={
"url": "https://your-app.com/report/42",
"format": "png",
"full_page": True,
"width": 1280,
},
timeout=90,
)
resp.raise_for_status()
with open("full.png", "wb") as f:
f.write(resp.content)
print(resp.headers.get("X-Page-Height"), "# measured document height in CSS px")
Very tall pages hit a documented cap rather than an out-of-memory surprise: images are cut off at 20,000 CSS px, and the response says so explicitly — X-Full-Page-Truncated: 1 plus X-Page-Height with the real document height. If you need everything past the cap, ask for "tile": true and the render returns a ZIP of overlapping numbered tiles instead (covered in its own guide, linked below).
Sticky headers are the classic full-page artifact — a bar designed to follow the viewport can repeat down a scrolled capture. If a page renders oddly, try "wait_until": "networkidle" first so animations and late images settle before the scroll pass.
Same endpoint, one more trick: if the page you are rendering has a form on it, adding "pdf_forms": true to a PDF render brings it back with real, fillable AcroForm fields — a PDF people can type into, not a picture of one. How that works.
Notes for requests
Three requests-specific details the sample already handles. resp.content is the binary body — resp.text would decode PDF bytes as text and corrupt them. raise_for_status() turns a JSON error response into an exception instead of letting it reach the open(..., "wb") call. And requests has no default timeout — without the explicit timeout= a hung connection blocks forever, which matters for a call that drives a real browser and legitimately takes seconds.
Response headers worth reading
| Header | Meaning |
|---|---|
X-Page-Height | Full document height in CSS px. |
X-Full-Page-Truncated | 1 when the image stops at the 20,000 px cap. |
X-Full-Page-Max-Height | The cap itself. |
Full parameter reference: the docs. Hard numbers on caps and timeouts: limits.
Related guides
Same task, other stacks
- Take a full-page screenshot in Python with httpx
- Take a full-page screenshot in Node.js with built-in fetch
- Take a full-page screenshot in Node.js with axios
- Take a full-page screenshot in PHP with cURL extension
- Take a full-page screenshot in Ruby with Net::HTTP
More with Python + requests
- Convert an HTML form to a fillable PDF
- Get a fillable PDF of just the form — no nav, no footer
- Generate a fillable invoice PDF from a web page
- Turn an online registration form into a fillable PDF
- Wait for a JavaScript-rendered form, then make it fillable
- Verify a fillable PDF render without opening the file
- Convert a URL to PDF
- Capture very tall pages as numbered tiles
- Take a retina-quality (2x) screenshot
- Take a JPEG screenshot at a custom viewport size
- Use the 24-hour render cache to cut costs
- Take a screenshot of a URL
- Capture a JavaScript-heavy page after it settles
- Wait for a specific element before capturing
- Add page numbers and headers to a PDF