Skip to main content
You can call the Screenshotly API directly from the command line using cURL.

Capture a screenshot (binary)

The default response returns the image binary directly:
curl -X POST https://api.screenshotly.dev/v1/capture \
  -H "X-API-Key: $SCREENSHOTLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com"}' \
  --output screenshot.png

Capture with GET request

Use query parameters for a simple GET request:
curl "https://api.screenshotly.dev/v1/capture?url=https://example.com&api_key=$SCREENSHOTLY_API_KEY" \
  --output screenshot.png

Capture with JSON response

Set response_type to json to get metadata instead of binary:
curl -X POST https://api.screenshotly.dev/v1/capture \
  -H "X-API-Key: $SCREENSHOTLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "options": {
      "format": "png",
      "response_type": "json"
    }
  }'
Response:
{
  "success": true,
  "data": {
    "id": "67b8a1c2d3e4f5a6b7c8d9e0",
    "url": "https://example.com",
    "image_url": "https://cdn.screenshotly.dev/screenshots/67b8a1c2d3e4f5a6b7c8d9e0.png",
    "status": "completed",
    "metadata": {
      "file_size": 245760,
      "format": "png",
      "dimensions": { "width": 1280, "height": 1024 }
    }
  },
  "remaining_credits": 99
}

Full-page JPEG with custom viewport

curl -X POST https://api.screenshotly.dev/v1/capture \
  -H "X-API-Key: $SCREENSHOTLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "options": {
      "format": "jpeg",
      "image_quality": 85,
      "full_page": true,
      "viewport_width": 1440,
      "viewport_height": 900
    }
  }' \
  --output screenshot.jpg

Check screenshot status

curl https://api.screenshotly.dev/v1/screenshots/67b8a1c2d3e4f5a6b7c8d9e0/status \
  -H "X-API-Key: $SCREENSHOTLY_API_KEY"

Mobile device emulation

curl -X POST https://api.screenshotly.dev/v1/capture \
  -H "X-API-Key: $SCREENSHOTLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "options": {
      "viewport_width": 390,
      "viewport_height": 844,
      "device_scale_factor": 3,
      "viewport_mobile": true,
      "viewport_has_touch": true
    }
  }' \
  --output mobile.png

Dark mode with ad blocking

curl -X POST https://api.screenshotly.dev/v1/capture \
  -H "X-API-Key: $SCREENSHOTLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "options": {
      "dark_mode": true,
      "block_ads": true,
      "block_cookie_banners": true
    }
  }' \
  --output clean-dark.png

Reusable shell script

#!/bin/bash
# screenshot.sh - capture a screenshot of a URL
URL="${1:?Usage: screenshot.sh <url> [format]}"
FORMAT="${2:-png}"

curl -s -X POST https://api.screenshotly.dev/v1/capture \
  -H "X-API-Key: $SCREENSHOTLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"url\": \"$URL\", \"options\": {\"format\": \"$FORMAT\", \"response_type\": \"json\"}}" | jq .
Usage:
chmod +x screenshot.sh
./screenshot.sh https://example.com jpeg