Keyword: screenshot api tutorial · Updated

Screenshot API Quick Start: Your First Screenshot in 60 Seconds

The fastest path from zero to a working website screenshot rendered by an API. Sign up, copy your key, run one curl command, get back a PNG. Then move to Node.js, Python, or PHP and let an AI agent call it through MCP — all without leaving this page.

TL;DR — 60 seconds, three commands

  1. Sign up at dashboard.snapshotflow.com (300 free screenshots for the lifetime of the account, no credit card).
  2. Copy the API key from the dashboard.
  3. Run the snippet below and open the PNG.
export SNAPSHOTFLOW_KEY=sk_live_xxxxxxxxxxxx
curl "https://api.snapshotflow.com/screenshot?url=https://stripe.com&full_page=true" \
  -H "X-Api-Key: $SNAPSHOTFLOW_KEY" --output stripe.png
open stripe.png
Why one HTTP call is enough: SnapshotFlow keeps a warm browser pool (Puppeteer over Chromium) behind the /screenshot endpoint. You skip dependency installs, font setup, Lambda layers, and concurrency tuning — that complexity stays on the vendor's side. See What Is a Screenshot API? for the full architecture diagram.

Prerequisites

You need exactly two things:

  • A terminal with curl (preinstalled on macOS and Linux; available on Windows 10+ via PowerShell).
  • An email address for the SnapshotFlow free starter quota — 300 screenshots for the lifetime of the account, no credit card.

That's it. No SDK install, no headless Chrome on your machine, no Docker.

Step 1 — Create an account and copy your API key

1

Open dashboard.snapshotflow.com/#/register and sign up with an email + password (or magic link). Email verification arrives instantly.

2

Inside the dashboard, open API Keys. A first key is generated automatically — labelled default. Click Copy.

3

Export the key as a shell variable so you never paste it inline:

export SNAPSHOTFLOW_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Windows PowerShell: $env:SNAPSHOTFLOW_KEY="sk_live_...".

Security note: never commit the key to git. Treat it like a database password — store it in .env, GitHub Actions secrets, or your platform's secret manager.

Step 2 — Your first screenshot with curl

The /screenshot endpoint accepts a single required query parameter — url — and returns the raw image bytes. The header X-Api-Key authenticates the request.

curl "https://api.snapshotflow.com/screenshot?url=https://example.com" \
  -H "X-Api-Key: $SNAPSHOTFLOW_KEY" \
  --output example.png

After roughly a second, example.png lands in your working directory. Open it with your image viewer — you should see example.com rendered exactly as Chromium would draw it on a 1280-wide viewport.

That's the entire happy path. The next sections layer parameters, languages, deployment options, and the agent integration on top of this same 3-line shape.

Step 3 — The five parameters you'll use most

The /screenshot endpoint supports more than 40 parameters (see the API reference). For 90% of use cases you only need these five:

ParameterDefaultWhat it does
url—Required. Any public URL. Must be URL-encoded if it contains query strings or special characters.
full_pagefalseCapture the entire scroll height, not just the visible viewport.
width1280Viewport width in pixels. Use 1440 for desktop hero shots, 375 for iPhone-sized previews.
formatpngpng, jpeg, or webp. WebP is ~30% smaller for the same visual quality.
wait_fornetworkidleWhen to consider the page "ready": networkidle, load, domcontentloaded, or a CSS selector like .hero-loaded.

Combining them is just URL composition:

curl "https://api.snapshotflow.com/screenshot?url=https://stripe.com&full_page=true&width=1440&format=webp&wait_for=networkidle" \
  -H "X-Api-Key: $SNAPSHOTFLOW_KEY" \
  --output stripe-full.webp

For long-page nuances (lazy images, sticky headers, infinite scroll) read Full Page Screenshot API: How to Capture Long Web Pages Without Cropping or Bugs.

Step 4 — From your language: Node.js, Python, PHP

The API is plain HTTP, so any language with a request library works the same way. Below are the three most common snippets, all calling the identical endpoint.

Prefer a client library? The official Node.js SDK (npm install snapshotflow, GitHub) and Java SDK (com.snapshotflow:snapshotflow-java, GitHub) install wherever your code runs — a laptop, a server, a CI runner or a Docker container — and call the same API. Screenshots still render on SnapshotFlow servers.

Node.js / TypeScript

import { writeFile } from "node:fs/promises";

const url = new URL("https://api.snapshotflow.com/screenshot");
url.searchParams.set("url", "https://stripe.com");
url.searchParams.set("full_page", "true");
url.searchParams.set("width", "1440");

const res = await fetch(url, {
  headers: { "X-Api-Key": process.env.SNAPSHOTFLOW_KEY! },
});

if (!res.ok) throw new Error(`SnapshotFlow ${res.status}: ${await res.text()}`);
await writeFile("stripe.png", Buffer.from(await res.arrayBuffer()));

Python

import os, requests

res = requests.get(
    "https://api.snapshotflow.com/screenshot",
    params={
        "url": "https://stripe.com",
        "full_page": "true",
        "width": 1440,
    },
    headers={"X-Api-Key": os.environ["SNAPSHOTFLOW_KEY"]},
    timeout=30,
)
res.raise_for_status()
with open("stripe.png", "wb") as f:
    f.write(res.content)

PHP (Guzzle)

<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();
$res = $client->get('https://api.snapshotflow.com/screenshot', [
    'query'   => ['url' => 'https://stripe.com', 'full_page' => 'true', 'width' => 1440],
    'headers' => ['X-Api-Key' => getenv('SNAPSHOTFLOW_KEY')],
    'timeout' => 30,
]);

file_put_contents('stripe.png', $res->getBody());

Ruby, Go, Java, C#, Rust, Elixir — the recipe is the same: GET request, one header, one query string, write the response body as binary. We publish language-specific guides as part of our blog series.

Step 5 — Let an AI agent call it via MCP

This is where SnapshotFlow diverges from older screenshot APIs. Instead of forcing your LLM agent to learn the HTTP shape, SnapshotFlow exposes the same operations as tools through the Model Context Protocol.

Two surfaces are available out of the box:

  • Remote MCP server at https://api.snapshotflow.com/mcp — point Claude Desktop, Cursor, Goose, or any MCP-aware client at it.
  • WebMCP via navigator.modelContext — on snapshotflow.com pages, a browser agent can call open_page, build_screenshot_request and run_screenshot. run_screenshot sends the request to the same hosted API with the key pasted into the playground, so the capture still renders on SnapshotFlow servers.

In Claude, add https://api.snapshotflow.com/mcp as a custom connector under Settings → Connectors. In Cursor's MCP settings it is one JSON entry:

{
  "mcpServers": {
    "snapshotflow": {
      "url": "https://api.snapshotflow.com/mcp"
    }
  }
}

The endpoint uses OAuth, so the client opens a browser to sign in on first connect; no API key goes into the config. Other clients are covered on the MCP setup page.

Once registered, the agent can be asked in natural language — "Take a full-page screenshot of stripe.com at 1440 wide and save it to disk" — and the tool call is routed to the same /screenshot endpoint you used in step 2.

No agent stack yet? Skip step 5 for now. The HTTP path you finished in step 4 is fully production-grade — the MCP layer is purely additive.

Production checklist

Before you wire the API into a customer-facing flow, walk through the seven items below. They're the smallest delta between a 3-line script and something that won't page you at 2 a.m.

  • Store the key as a secret. Never inline it in client-side JS. Browser-callable rendering should use a server-side proxy or our signed URLs.
  • Set a sensible timeout. 25–30 s on the client; the API guarantees a response or 504 before that.
  • Cache the response. If the URL + parameters are stable, store the PNG in S3 / R2 / GCS keyed by the request hash. SnapshotFlow also returns an ETag header.
  • Handle 429 Too Many Requests. Apply exponential backoff with jitter and watch the X-Quota-* headers to understand remaining units.
  • Pin wait_for. The default networkidle covers most pages, but on apps with long-polling or analytics beacons you want a stable CSS selector.
  • Pick a format intentionally. WebP saves ~30% bytes; JPEG is best for hero images; PNG is best for OG cards where transparency or pixel-precision matters.
  • Log failures with the full request URL and JSON body. Include the response body when contacting support so the render can be reproduced quickly.

Troubleshooting common errors

StatusWhat it meansFix
401Missing or invalid API key.Re-export SNAPSHOTFLOW_KEY; verify the value matches the dashboard. New keys activate immediately.
402Free lifetime quota exhausted.Upgrade in the dashboard for paid usage.
422Invalid parameter combination, e.g. format=avif (not yet supported) or width=0.Check the parameter reference for allowed values.
504Target page didn't reach the wait_for condition in time.Switch wait_for to load or to a CSS selector that signals readiness.
Image is blankPage has a cookie wall, geo-block, or login form.Pass headers + cookies parameters. For region-specific pages, see the geo-targeted screenshot guide.

FAQ

How long does it really take to get my first screenshot?

About 60 seconds end-to-end — ~30 seconds to sign up, ~5 seconds to copy the API key, ~3–5 seconds for the first call. Warm-pool calls afterwards return in 150–900 ms.

Do I need a credit card?

No. The free starter quota includes 300 screenshots for the lifetime of the account with no card on file. You only enter billing when you upgrade to paid usage.

Can I run it on my own server?

Your code can: install the Node.js or Java SDK, or call the API from any HTTP client, on your own server, a laptop or in a Docker container. The capture itself always renders on SnapshotFlow servers, so the target page must be publicly reachable; for pages that exist only on your machine or private network, expose an access-controlled preview on a public URL.

Which languages have ready-made examples?

This guide ships snippets for curl, Node.js / TypeScript, Python and PHP. Because the API is plain HTTP, any language with an HTTP client works — Ruby, Go, Java, C#, Rust, Elixir, Kotlin, Swift, etc.

How do I let an AI agent take screenshots?

Point your MCP-aware client at https://api.snapshotflow.com/mcp (Claude Desktop, Cursor, Goose, etc.) or use the WebMCP tools registered through navigator.modelContext. The same operations become first-class tools the model can call by name.

Where do I see all the parameters?

The full reference lives in the API docs. Forty-plus parameters are documented, but in practice fewer than ten cover most production needs — the five from step 3 are a good starting set.

Try SnapshotFlow free

300 free screenshots for the lifetime of the account, MCP-ready. No credit card.