Screenshot API for Node.js

Capture screenshots, PDFs and OG images from Node.js with the official TypeScript SDK, plain fetch, or the CLI.

There is an official SDK on npm (getsnap), written in TypeScript with bundled types. It also ships a CLI, so you can capture something from a terminal without writing any code.

Install

npm install getsnap

Your first screenshot in Node.js

One POST, one JSON body, one URL back. The response is a CDN link to the finished image.

Node.js SDK

import GetSnap from "getsnap";

const snap = new GetSnap("sk_live_YOUR_KEY");

const { url } = await snap.screenshot({
  url: "https://github.com",
  format: "png",
});
console.log(url); // CDN URL to your screenshot

fetch (no SDK)

const response = await fetch("https://api.getsnap.dev/v1/screenshot", {
  method: "POST",
  headers: {
    "X-API-Key": "sk_live_YOUR_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://github.com", format: "png" }),
});

const data = await response.json();
console.log(data.url);

From the command line

The SDK installs a CLI, which is the fastest way to confirm your key works:

export GETSNAP_KEY=sk_live_YOUR_KEY

npx getsnap screenshot https://news.ycombinator.com
npx getsnap screenshot https://news.ycombinator.com --out hn.png
npx getsnap pdf        https://news.ycombinator.com --out hn.pdf --full-page
npx getsnap og         https://blog.example.com/post --out og.png

Full-page captures and other options

Every option is a field in the same JSON body. The common ones are full-page capture, popup and ad removal, viewport size, and lazy-load scrolling.

const result = await snap.screenshot({
  url: "https://example.com",
  format: "png",
  viewport_width: 1280,
  viewport_height: 720,
  full_page: true,
  remove_popups: true,
  block_ads: true,
  lazy_load: true,
  extract_text: true,
});
console.log(result.url);

Saving the image to disk

By default you get a CDN URL. Ask for a binary response instead and you get the bytes directly, which saves a round-trip when you are storing the file yourself.

import { writeFile } from "fs/promises";

const buffer = await snap.screenshotBinary({
  url: "https://example.com",
  format: "webp",
  quality: 90,
});
await writeFile("screenshot.webp", Buffer.from(buffer));

Handling errors

Every failure returns JSON with an error code and a human-readable message. These are the ones worth branching on:

StatuserrorWhat it means
400validation_errorA field is missing or out of range. The body names the field.
401unauthorizedMissing or unknown API key.
402quota_exceededMonthly capture limit reached.
429rate_limit_exceededToo many requests this minute. Back off and retry.
500capture_failedThe page could not be rendered - usually a timeout on a page that never settles.
const response = await fetch("https://api.getsnap.dev/v1/screenshot", {
  method: "POST",
  headers: {
    "X-API-Key": "sk_live_YOUR_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://example.com" }),
});

if (!response.ok) {
  // e.g. { error: "quota_exceeded", message: "..." }
  const { error, message } = await response.json();
  throw new Error(`${response.status} ${error}: ${message}`);
}

const { url } = await response.json();

Rate limits and quotas

PlanCaptures / monthRequests / minute
Free1005
Starter5,00030
Pro25,00060
Business100,000120

Exceeding the per-minute limit returns 429; exceeding the monthly quota returns 402. See pricing for the full breakdown.

Frequently asked questions

Is there an official Node.js SDK for taking screenshots?

Yes. There is an official Node.js SDK that wraps the REST API and returns parsed results. It is optional - the API is a single JSON POST, so a plain HTTP client works identically.

Do I need to run or manage a headless browser?

No. getSnap.dev runs Chromium server-side and returns a finished image, PDF or video. You never install Playwright or Puppeteer, and you never maintain a browser pool.

Is there a free tier?

Yes - 100 captures a month at 5 requests a minute, with no credit card required. Paid plans start at $9/month for 5,000 captures at 30 requests a minute.

How do I capture a page that requires login from Node.js?

Pass your own cookies or HTTP headers in the request body and the capture runs authenticated. Use a dedicated least-privilege account rather than your own session.

Next steps

Related reading

Start capturing from Node.js

100 screenshots a month on the free tier. No credit card required.

Get Free API Key