Guides · Python · httpx
Capture very tall pages as numbered tiles in Python with httpx
A single image has a height cap (20,000 CSS px) because somewhere past that, image viewers and memory both give up. "tile": true is the opt-in for pages that run past it: instead of cutting the capture off, the API returns a ZIP of numbered PNG tiles that cover the entire document.
Below is a complete, runnable Python program using httpx (pip install httpx). It reads your API key from the SNAPDOK_KEY environment variable — free keys take about thirty seconds and need no card.
import os
import httpx
resp = httpx.post(
"https://snapdok.io/v1/render",
headers={"Authorization": "Bearer " + os.environ["SNAPDOK_KEY"]},
json={
"url": "https://your-app.com/changelog",
"format": "png",
"full_page": True,
"tile": True,
},
timeout=90,
)
resp.raise_for_status()
with open("page-tiles.zip", "wb") as f:
f.write(resp.content)
print(resp.headers.get("X-Tiles"), "# how many parts are in the ZIP")
The tiles overlap on purpose: each part starts 80 px above where the previous one ended, so the seam appears in both images and nothing can fall into a gap — line up the repeated rows and you have the whole page. The archive includes a README stating each part's y-range, and the response carries the numbers too: X-Tiles (count), X-Tile-Overlap (the 80 px), and X-Page-Height.
Note the response type changes: with tiling you receive application/zip, not image/png — code that assumes an image must branch on Content-Type. Pages short enough for one image return a plain PNG even with tile set, so the branch is required, not theoretical. That asymmetry is deliberate: a screenshot is one image to almost everyone, so the archive only happens when you asked for it and the page needs it.
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 httpx
httpx looks like requests but differs where it bites: it ships a 5-second default timeout, which a render that drives a real browser will blow through on heavier pages — hence the explicit timeout=90. raise_for_status() exists and behaves the same. If you are on asyncio already, the same call works with httpx.AsyncClient and await client.post(...) — the request body and headers are identical.
Response headers worth reading
| Header | Meaning |
|---|---|
Content-Type | application/zip when tiled, image/png when not needed. |
X-Tiles | Number of parts in the archive. |
X-Tile-Overlap | Vertical overlap between parts, in CSS px. |
Full parameter reference: the docs. Hard numbers on caps and timeouts: limits.
Related guides
Same task, other stacks
- Capture very tall pages as numbered tiles in Python with requests
- Capture very tall pages as numbered tiles in Node.js with built-in fetch
- Capture very tall pages as numbered tiles in Node.js with axios
- Capture very tall pages as numbered tiles in PHP with cURL extension
- Capture very tall pages as numbered tiles in Ruby with Net::HTTP
More with Python + httpx
- Convert a URL to PDF
- Take a full-page screenshot
- 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