Build a Website Thumbnail Generator with a Screenshot API
Generate website thumbnails automatically for link previews, directories, and portfolios — using a simple API instead of running your own browser infrastructure.
Website thumbnails are everywhere — link previews in chat apps, site directories, bookmark managers, portfolio showcases, and SaaS dashboards that display customer websites. If you're building any of these, you need a reliable way to generate thumbnails from URLs.
The naive approach is to run a headless browser, capture a full screenshot, then resize it. That works until you need to handle hundreds of URLs, and suddenly you're managing Chromium instances, queueing jobs, and fighting memory limits. A thumbnail API removes all of that complexity.
How a Thumbnail API Works
A thumbnail API takes a URL, renders the page in a real browser on the server, captures a screenshot, and returns the image — all in one HTTP request. You control the viewport size, output format, and dimensions.
With API Snap's Screenshot endpoint, generating a website thumbnail is a single call:
curl "https://api-snap.com/api/screenshot?url=https://stripe.com&width=1280&height=800&format=webp" \
-H "Authorization: Bearer snp_your_api_key" \
-o stripe-thumbnail.webpFor smaller thumbnails, you can combine this with the Image Resize endpoint to crop and resize to your exact target dimensions.
Building a Thumbnail Service
Here's a practical pattern: capture screenshots via the API, resize them, and cache the results for fast retrieval.
Node.js — Generate and Resize in Two Steps
async function generateThumbnail(siteUrl) {
// Step 1: Capture the full-size screenshot
const screenshot = await fetch(
`https://api-snap.com/api/screenshot?url=${encodeURIComponent(siteUrl)}&width=1280&height=800&format=png`,
{ headers: { Authorization: `Bearer ${process.env.SNAPAPI_KEY}` } }
);
const fullImage = Buffer.from(await screenshot.arrayBuffer());
// Step 2: Resize to thumbnail dimensions
const thumbnail = await fetch("https://api-snap.com/api/resize", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SNAPAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: `data:image/png;base64,${fullImage.toString("base64")}`,
width: 320,
height: 200,
fit: "cover",
format: "webp",
}),
});
return Buffer.from(await thumbnail.arrayBuffer());
}Python — Quick Thumbnail Generation
import requests
def generate_thumbnail(site_url, api_key):
resp = requests.get(
"https://api-snap.com/api/screenshot",
params={
"url": site_url,
"width": 1280,
"height": 800,
"format": "webp",
},
headers={"Authorization": f"Bearer {api_key}"},
)
resp.raise_for_status()
return resp.content
# Save it
thumbnail = generate_thumbnail("https://stripe.com", SNAPAPI_KEY)
with open("thumbnail.webp", "wb") as f:
f.write(thumbnail)Real-World Use Cases
Site Directory or Marketplace
If you're building a directory of websites (think Product Hunt, a template marketplace, or a link aggregator), you need thumbnails for every listing. Generate them on submission, cache them in your CDN, and refresh periodically.
Bookmark Manager
When a user saves a URL, capture a thumbnail alongside the URL metadata (title, description, favicon). This gives your bookmark cards a rich visual preview without requiring the user to upload anything.
Portfolio Showcase
Agencies and freelancers can automatically generate thumbnails of client websites. Set up a cron job to refresh thumbnails weekly so the portfolio always shows current designs.
SaaS Dashboard
If your product manages customer websites (monitoring, analytics, hosting), display thumbnails in the dashboard for quick visual identification.
Caching Strategy
Websites change, but not every minute. A sensible caching strategy saves API calls and keeps thumbnails fast:
- Cache thumbnails in your CDN or object storage (S3, R2, GCS)
- Set a TTL of 24-72 hours for most use cases
- Let users manually refresh if they know a site has changed
- Use WebP format for the best size-to-quality ratio
Pricing for Thumbnail Generation
Thumbnail generation typically involves one screenshot call per URL. The free plan (100 calls/month) lets you prototype. For a directory with 1,000 listings refreshed weekly, you'd need ~4,000 calls/month — the Hobby plan ($9/mo, 5,000 calls) covers it. For a full pricing comparison with other services, check our screenshot API pricing guide.
Get Started
Create a free account, grab your API key, and generate your first thumbnail in seconds. No browser infrastructure, no queue management — just HTTP requests and images.