Guides · Node.js · built-in fetch
Capture very tall pages as numbered tiles in Node.js with built-in fetch
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 Node.js program using built-in fetch, no third-party dependency needed. It reads your API key from the SNAPDOK_KEY environment variable — free keys take about thirty seconds and need no card.
import { writeFile } from "node:fs/promises";
const res = await fetch("https://snapdok.io/v1/render", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SNAPDOK_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://your-app.com/changelog",
format: "png",
full_page: true,
tile: true,
}),
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
await writeFile("page-tiles.zip", Buffer.from(await res.arrayBuffer()));
console.log(res.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 built-in fetch
No dependency needed: fetch is global from Node 18 onward (snapdok's own test suite uses it). The binary-safety detail is res.arrayBuffer() → Buffer.from(...) — reaching for res.text() is the classic way to corrupt a PDF in Node. fetch does not reject on HTTP error statuses, so the res.ok check is load-bearing: without it, an expired key writes a 40-byte JSON error to disk with a .pdf extension.
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 Python with httpx
- 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 Node.js + built-in fetch
- 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
- 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