How to Capture Website Screenshots with an API in 2025
Learn how to programmatically capture website screenshots using a screenshot API. Step-by-step guide with code examples in JavaScript, Python, and cURL.
Capturing website screenshots programmatically is essential for many modern applications — from generating social media previews to building visual regression testing pipelines. In this guide, we'll walk through how to use a screenshot API to capture any webpage as an image with a single HTTP request.
Why Use a Screenshot API?
Running headless browsers locally is fragile and resource-intensive. A screenshot API handles the complexity for you:
- No infrastructure to manage — No Puppeteer, Playwright, or Chrome installations required
- Consistent results — Same rendering engine across every request
- Global edge delivery — Low-latency screenshots from anywhere in the world
- Format flexibility — PNG, JPEG, WebP, and PDF output with a single parameter
Getting Started with PxShot
PxShot is a screenshot API that lets you capture any URL as an image. Here's how to get started:
Step 1: Get Your API Key
Sign up at pxshot.dev/dashboard and create an API key. The free tier includes 100 screenshots per month.
Step 2: Make Your First Request
A basic screenshot request looks like this:
curl "https://pxshot.dev/api/capture?url=https://example.com&api_key=YOUR_KEY"
Step 3: Customize the Output
You can control the viewport size, output format, quality, and more:
curl "https://pxshot.dev/api/capture?url=https://example.com&width=1280&height=720&format=webp&quality=90&api_key=YOUR_KEY"
Code Examples
JavaScript (Node.js / Fetch)
const response = await fetch(
'https://pxshot.dev/api/capture?url=https://example.com&format=png&api_key=YOUR_KEY'
);
const imageBuffer = await response.arrayBuffer();
// Save to file or process the image
Python
import requests
response = requests.get(
'https://pxshot.dev/api/capture',
params={'url': 'https://example.com', 'format': 'png', 'api_key': 'YOUR_KEY'}
)
with open('screenshot.png', 'wb') as f:
f.write(response.content)
Common Use Cases
- Open Graph previews — Generate dynamic OG images for blog posts and landing pages
- Link previews — Show visual thumbnails of URLs in chat apps and dashboards
- Archival — Capture point-in-time snapshots of pages for compliance or records
- Visual testing — Compare screenshots across deployments to catch regressions
Ready to try it? Get your free API key and start capturing screenshots in under a minute.