API Documentation

Welcome to the ScreenshotAPI documentation. This guide will help you integrate our screenshot service into your application.

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer sk_your_api_key

You can also use the X-API-Key header:

X-API-Key: sk_your_api_key

Rate Limits

Rate limits depend on your plan:

PlanRequests/minuteScreenshots/month
Free10100
Starter301,000
Pro605,000
Business12025,000

Rate limit information is included in response headers:

X-RateLimit-Limit: 30
X-RateLimit-Remaining: 29
X-RateLimit-Reset: 45
X-Usage-Limit: 1000
X-Usage-Used: 150
X-Usage-Remaining: 850

Screenshot Endpoint

POST /v1/screenshot

Capture a screenshot of any webpage.

Request Body

ParameterTypeRequiredDescription
urlstringYesThe URL to capture
formatstringNoOutput format: png, jpeg, webp (default: png)
widthnumberNoViewport width in pixels (default: 1280, max: 3840)
heightnumberNoViewport height in pixels (default: 720, max: 2160)
fullPagebooleanNoCapture full scrollable page (default: false)
mobilebooleanNoEmulate mobile device (default: false)
delaynumberNoWait ms before capture (max: 10000)
selectorstringNoCSS selector to capture specific element
qualitynumberNoJPEG/WebP quality 1-100 (default: 80)
scalenumberNoDevice scale factor 1-3 (default: 1)
darkModebooleanNoPrefer dark color scheme (default: false)
timeoutnumberNoPage load timeout in ms (max: 55000)
returnTypestringNourl, base64, or binary (default: url)

Example Request

curl -X POST https://api.screenshotapi.dev/v1/screenshot \
  -H "Authorization: Bearer sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "format": "png",
    "width": 1280,
    "height": 720,
    "fullPage": true
  }'

Example Response

{
  "success": true,
  "data": {
    "url": "https://screenshots.screenshotapi.dev/abc123.png",
    "width": 1280,
    "height": 2400,
    "format": "png",
    "size": 245678,
    "expiresAt": "2024-01-24T12:00:00.000Z"
  }
}

PDF Endpoint

POST /v1/pdf

Generate a PDF from any webpage.

Request Body

ParameterTypeRequiredDescription
urlstringYesThe URL to convert
formatstringNoPage format: A4, Letter, Legal (default: A4)
landscapebooleanNoLandscape orientation (default: false)
printBackgroundbooleanNoPrint background graphics (default: true)
scalenumberNoScale factor 0.1-2 (default: 1)
marginobjectNoPage margins: { top, right, bottom, left }

Example Request

curl -X POST https://api.screenshotapi.dev/v1/pdf \
  -H "Authorization: Bearer sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "format": "A4",
    "printBackground": true
  }'

Usage Endpoint

GET /v1/usage

Get your current usage statistics.

Example Response

{
  "success": true,
  "data": {
    "plan": "starter",
    "period": {
      "start": "2024-01-01",
      "end": "2024-01-31"
    },
    "usage": {
      "screenshots": 150,
      "limit": 1000,
      "remaining": 850,
      "percentUsed": 15
    },
    "rateLimit": {
      "requestsPerMinute": 30
    }
  }
}

Error Codes

CodeHTTP StatusDescription
INVALID_API_KEY401Invalid or missing API key
RATE_LIMIT_EXCEEDED429Too many requests per minute
USAGE_LIMIT_EXCEEDED402Monthly usage limit exceeded
INVALID_URL400Invalid URL format
INVALID_PARAMETERS400Invalid request parameters
SCREENSHOT_FAILED500Failed to capture screenshot
TIMEOUT504Request timed out

Code Examples

JavaScript (Node.js)

const response = await fetch('https://api.screenshotapi.dev/v1/screenshot', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sk_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    url: 'https://example.com',
    format: 'png',
    fullPage: true
  })
});

const data = await response.json();
if (data.success) {
  console.log('Screenshot URL:', data.data.url);
}

Python

import requests

response = requests.post(
    'https://api.screenshotapi.dev/v1/screenshot',
    headers={
        'Authorization': 'Bearer sk_your_api_key',
        'Content-Type': 'application/json'
    },
    json={
        'url': 'https://example.com',
        'format': 'png',
        'fullPage': True
    }
)

data = response.json()
if data['success']:
    print('Screenshot URL:', data['data']['url'])

PHP

<?php
$ch = curl_init('https://api.screenshotapi.dev/v1/screenshot');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer sk_your_api_key',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'url' => 'https://example.com',
    'format' => 'png',
    'fullPage' => true
]));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
if ($data['success']) {
    echo 'Screenshot URL: ' . $data['data']['url'];
}