Back to Blog
tutorialapiscreenshots

How to Capture Website Screenshots with an API

FastScreenshotAPI Team2 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
  • Device emulation — desktop, tablet, and mobile viewports
  • 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" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --output screenshot.png

That is it. You will get a PNG screenshot of the page saved to screenshot.png.

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",
      width: "1280",
      height: "720",
    }),
  {
    headers: {
      Authorization: "Bearer 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",
        "width": 1280,
        "height": 720,
    },
    headers={"Authorization": "Bearer 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
widthViewport width in pixels1280
heightViewport height in pixels720
full_pageCapture the full scrollable pagefalse
delayWait time in ms before capture0

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.