How to Take a Website Screenshot with an API
Taking screenshots of websites programmatically usually means setting up Puppeteer, Selenium, or Playwright. That's a headless browser, a Node.js or Python runtime, gigabytes of Chromium dependencies, and configuration that breaks on every OS update.
Or you can make one HTTP request.
The Simplest Screenshot
curl "https://hermesforge.dev/api/screenshot?url=https://example.com" -o screenshot.png
That's it. No API key needed for basic usage. The response is a PNG image.
Python
import urllib.request
url = "https://hermesforge.dev/api/screenshot?url=https://example.com"
urllib.request.urlretrieve(url, "screenshot.png")
With the requests library:
import requests
response = requests.get(
"https://hermesforge.dev/api/screenshot",
params={"url": "https://example.com", "format": "webp"}
)
with open("screenshot.webp", "wb") as f:
f.write(response.content)
JavaScript (Node.js)
const https = require('https');
const fs = require('fs');
const url = 'https://hermesforge.dev/api/screenshot?url=https://example.com&format=png';
https.get(url, (res) => {
const file = fs.createWriteStream('screenshot.png');
res.pipe(file);
});
With fetch (Node 18+):
const response = await fetch(
'https://hermesforge.dev/api/screenshot?url=https://example.com&format=webp'
);
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync('screenshot.webp', buffer);
Common Options
| Parameter | Description | Example |
|---|---|---|
url |
Target URL (required) | https://example.com |
format |
Output format: png, jpeg, webp, pdf | webp |
width |
Viewport width in pixels | 1920 |
height |
Viewport height in pixels | 1080 |
full_page |
Capture entire scrollable page | true |
dark_mode |
Force dark color scheme | true |
delay |
Wait N ms before capture | 3000 |
scale |
Device pixel ratio (1-3) | 2 |
quality |
JPEG/WebP quality (1-100) | 85 |
selector |
Capture specific CSS element | .main-content |
block_ads |
Remove ads and trackers | true |
Mobile Screenshots
Use viewport presets to capture how a site looks on specific devices:
# iPhone 14 Pro
curl "https://hermesforge.dev/api/screenshot?url=https://example.com&viewport=iphone14pro" -o mobile.png
# iPad
curl "https://hermesforge.dev/api/screenshot?url=https://example.com&viewport=ipad" -o tablet.png
Available presets: iphone12, iphone14pro, pixel7, galaxys23, ipad, ipadpro, and more.
Or set custom dimensions:
curl "https://hermesforge.dev/api/screenshot?url=https://example.com&width=375&height=812" -o custom.png
Full Page Screenshots
Capture the entire scrollable page, not just the viewport:
curl "https://hermesforge.dev/api/screenshot?url=https://example.com&full_page=true" -o full.png
Dark Mode
Force the page to render in dark mode:
curl "https://hermesforge.dev/api/screenshot?url=https://github.com&dark_mode=true" -o dark.png
Retina / High-DPI
Capture at 2x or 3x resolution for crisp images:
curl "https://hermesforge.dev/api/screenshot?url=https://example.com&scale=2&format=webp&quality=90" -o retina.webp
Capture a Specific Element
Screenshot just one part of the page using a CSS selector:
curl "https://hermesforge.dev/api/screenshot?url=https://news.ycombinator.com&selector=table" -o table.png
Remove Cookie Banners and Ads
# Block known ad/tracker domains
curl "https://hermesforge.dev/api/screenshot?url=https://cnn.com&block_ads=true" -o clean.png
# Remove specific elements with custom JavaScript
curl "https://hermesforge.dev/api/screenshot?url=https://example.com&js=document.querySelector('.cookie-banner')?.remove()" -o no-banner.png
Wait for Dynamic Content
Single-page apps and dashboards need time to render:
# Wait 5 seconds for JavaScript to finish
curl "https://hermesforge.dev/api/screenshot?url=https://app.example.com&delay=5000" -o spa.png
# Wait for a specific element to appear
curl "https://hermesforge.dev/api/screenshot?url=https://app.example.com&wait_for=.dashboard-loaded" -o dashboard.png
PDF Export
Generate a PDF instead of an image:
curl "https://hermesforge.dev/api/screenshot?url=https://example.com&format=pdf&full_page=true" -o page.pdf
Batch Screenshots
Capture multiple URLs in one request (requires a free API key):
curl -X POST "https://hermesforge.dev/api/screenshot/batch" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_KEY" \
-d '{"urls": ["https://example.com", "https://github.com"], "format": "webp"}'
Rate Limits
| Tier | Limit | Cost |
|---|---|---|
| Anonymous | 2/min, 10/day | Free |
| API Key | 50/day | Free |
| Pro | 1000/day | $9 / 30 days |
| Ultra | 5000/day | $29 / 30 days |
Get a free API key instantly — no credit card, no signup form:
curl -X POST "https://hermesforge.dev/api/keys" \
-H "Content-Type: application/json" \
-d '{}'
Why Not Just Use Puppeteer?
You can. But consider what you need to maintain:
- Node.js runtime
- Chromium binary (~300MB)
- Launch config (headless mode, sandbox flags, proxy settings)
- Page lifecycle management (timeouts, error handling, memory leaks)
- Server resources (each browser instance uses 200-500MB RAM)
- Updates when Chrome APIs change
An API call is one line. The tradeoff is control vs. simplicity. If you need pixel-perfect control over browser behavior, use Puppeteer. If you need a screenshot, use an API.