API Documentation

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

Authentication

All API requests require authentication via RapidAPI. Include these headers with every request:

X-RapidAPI-Key: YOUR_RAPIDAPI_KEY
X-RapidAPI-Host: screenshot-website-capture.p.rapidapi.com

Get your API key from RapidAPI.

Rate Limits

Rate limits depend on your RapidAPI subscription plan:

PlanPriceRequests/minuteScreenshots/month
Free$010100
Starter$9301,000
Pro$29605,000
Business$7912025,000

RapidAPI handles rate limiting automatically. Check your RapidAPI dashboard for current usage.

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://screenshot-website-capture.p.rapidapi.com/v1/screenshot \
  -H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: screenshot-website-capture.p.rapidapi.com" \
  -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://screenshot-api.wonderfulappstudio-paul-louis.workers.dev/files/abc123.png",
    "width": 1280,
    "height": 2400,
    "format": "png",
    "size": 245678,
    "expiresAt": "2025-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)
timeoutnumberNoPage load timeout in ms (max: 55000)
marginobjectNoPage margins: { top, right, bottom, left }

Example Request

curl -X POST https://screenshot-website-capture.p.rapidapi.com/v1/pdf \
  -H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: screenshot-website-capture.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "format": "A4",
    "printBackground": true
  }'

Usage Tracking

When using the API via RapidAPI, your usage is automatically tracked in your RapidAPI Dashboard.

You can view:

RapidAPI will return a 429 Too Many Requests error if you exceed your rate limit, and a 402 Payment Required if you exceed your monthly quota.

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://screenshot-website-capture.p.rapidapi.com/v1/screenshot', {
  method: 'POST',
  headers: {
    'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
    'X-RapidAPI-Host': 'screenshot-website-capture.p.rapidapi.com',
    '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://screenshot-website-capture.p.rapidapi.com/v1/screenshot',
    headers={
        'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
        'X-RapidAPI-Host': 'screenshot-website-capture.p.rapidapi.com',
        '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://screenshot-website-capture.p.rapidapi.com/v1/screenshot');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-RapidAPI-Key: YOUR_RAPIDAPI_KEY',
    'X-RapidAPI-Host: screenshot-website-capture.p.rapidapi.com',
    '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'];
}