This site is not affiliated with or endorsed by Cloudflare, Inc. It simply showcases experiments built using Cloudflare services.
Cloudflare Experiments

Screenshot API

Capture screenshots of any website from the edge using Cloudflare Browser Rendering

Capture screenshots of any website from Cloudflare's edge network using Browser Rendering and Puppeteer.

API Reference

GET /screenshot

Captures a PNG screenshot of the specified URL.

Prop

Type

Example Request

curl "https://your-worker.workers.dev/screenshot?url=https://www.cloudflare.com" \
  --output screenshot.png

Success Response

Returns a PNG image with the following headers:

Content-Type: image/png
Cache-Control: public, max-age=60

Error Response

error string

Human-readable error message

code string

Error code indicating the failure type

{
  "error": "Missing or invalid query parameter: url",
  "code": "INVALID_URL"
}

Error Codes

  • 400 - Missing or invalid url parameter (not http/https)
  • 502 - Screenshot operation failed (navigation timeout, unreachable site, rendering error)

Implementation Details

The API uses the following configuration:

  • Viewport: 1280x800 pixels
  • Wait condition: networkidle0 (waits until network is idle)
  • Navigation timeout: 20 seconds
  • Image format: PNG

Use Cases

  • Capture visual snapshots of web pages from the edge
  • Generate thumbnails or previews for link-sharing tools
  • Archive how a page looked at a point in time
  • Learn Browser Rendering with Puppeteer on Workers

Limitations

  • Requires Browser Rendering enabled on your Cloudflare account
  • Fixed 1280×800 viewport; no custom dimensions in this experiment
  • 20-second navigation timeout; networkidle0 may fail on busy sites
  • Local development needs npx wrangler dev --remote

Deployment

Enable Browser Rendering

This experiment requires Cloudflare Browser Rendering to be enabled on your account. Visit the Browser Rendering docs for setup instructions.

Deploy

Follow the deployment wizard to deploy the Worker to your Cloudflare account.

Local Development

cd apps/experiments/screenshot-api
npm install
npx wrangler dev --remote

Use --remote flag to access a real browser instance. Local development without this flag will not work as Browser Rendering requires Cloudflare infrastructure.

Test locally:

curl "http://localhost:8787/screenshot?url=https://www.cloudflare.com" \
  --output test.png

Cloudflare Features Used

On this page