Back to Blog
tutorialapiscreenshots

How to Capture Website Screenshots with an API

FastScreenshotAPI Team3 min read

Taking screenshots of websites programmatically is a common requirement for many applications — from generating link previews and building monitoring dashboards to creating visual regression tests. In this guide, we will walk through how to use FastScreenshotAPI to capture pixel-perfect screenshots with just a few lines of code.

Why Use a Screenshot API?

Running your own headless browser infrastructure is complex and expensive. You need to manage Chromium instances, handle timeouts, deal with cookie banners, wait for lazy-loaded content, and scale horizontally when traffic spikes. A screenshot API abstracts all of that away so you can focus on your product.

FastScreenshotAPI handles the hard parts for you:

  • Automatic waiting for pages to fully render, including JavaScript-heavy SPAs
  • Cookie banner dismissal so you get clean screenshots every time
  • Multiple formats — PNG, JPEG, WebP, and PDF
  • Desktop and mobile — a 1920×1080 desktop viewport, or a 390×844 mobile viewport with mobile=true
  • Full-page capture — not just the visible viewport

Quick Start with cURL

The simplest way to capture a screenshot:

bash
curl "https://api.fastscreenshotapi.com/v1/screenshot?url=https://example.com&format=png&response_type=binary" \
  -H "X-Api-Key: YOUR_API_KEY" \
  --output screenshot.png

That is it. You will get a PNG screenshot of the page saved to screenshot.png. Without response_type=binary, the API returns JSON with a signed download URL instead.

JavaScript Example

Using fetch in Node.js or any modern JavaScript environment:

javascript
const response = await fetch(
  "https://api.fastscreenshotapi.com/v1/screenshot?" +
    new URLSearchParams({
      url: "https://example.com",
      format: "png",
      full_page: "true",
      response_type: "binary",
    }),
  {
    headers: {
      "X-Api-Key": "YOUR_API_KEY",
    },
  }
);

const buffer = await response.arrayBuffer();
// Save or process the screenshot buffer

Python Example

python
import requests

response = requests.get(
    "https://api.fastscreenshotapi.com/v1/screenshot",
    params={
        "url": "https://example.com",
        "format": "png",
        "full_page": "true",
        "response_type": "binary",
    },
    headers={"X-Api-Key": "YOUR_API_KEY"},
)

with open("screenshot.png", "wb") as f:
    f.write(response.content)

Key Parameters

ParameterDescriptionDefault
urlThe URL to screenshotRequired
formatOutput format: png, jpeg, webp, pdfpng
mobileUse a 390×844 mobile viewport and user agentfalse
full_pageCapture the full scrollable pagefalse
delayExtra wait in ms after page load (0–10000)3000
response_typeurl (signed link), binary (raw image), or json (base64)url

What's Next?

Check out the API documentation for the full list of parameters, or try it out in the Playground to see results instantly. If you are dealing with cookie consent banners ruining your screenshots, read our guide on how we solved that problem.