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:
| Plan | Price | Requests/minute | Screenshots/month |
|---|---|---|---|
| Free | $0 | 10 | 100 |
| Starter | $9 | 30 | 1,000 |
| Pro | $29 | 60 | 5,000 |
| Business | $79 | 120 | 25,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
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | The URL to capture |
format | string | No | Output format: png, jpeg, webp (default: png) |
width | number | No | Viewport width in pixels (default: 1280, max: 3840) |
height | number | No | Viewport height in pixels (default: 720, max: 2160) |
fullPage | boolean | No | Capture full scrollable page (default: false) |
mobile | boolean | No | Emulate mobile device (default: false) |
delay | number | No | Wait ms before capture (max: 10000) |
selector | string | No | CSS selector to capture specific element |
quality | number | No | JPEG/WebP quality 1-100 (default: 80) |
scale | number | No | Device scale factor 1-3 (default: 1) |
darkMode | boolean | No | Prefer dark color scheme (default: false) |
timeout | number | No | Page load timeout in ms (max: 55000) |
returnType | string | No | url, 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
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | The URL to convert |
format | string | No | Page format: A4, Letter, Legal (default: A4) |
landscape | boolean | No | Landscape orientation (default: false) |
printBackground | boolean | No | Print background graphics (default: true) |
scale | number | No | Scale factor 0.1-2 (default: 1) |
timeout | number | No | Page load timeout in ms (max: 55000) |
margin | object | No | Page 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:
- Current month's API calls
- Remaining quota
- Billing history
- Rate limit status
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
| Code | HTTP Status | Description |
|---|---|---|
INVALID_API_KEY | 401 | Invalid or missing API key |
RATE_LIMIT_EXCEEDED | 429 | Too many requests per minute |
USAGE_LIMIT_EXCEEDED | 402 | Monthly usage limit exceeded |
INVALID_URL | 400 | Invalid URL format |
INVALID_PARAMETERS | 400 | Invalid request parameters |
SCREENSHOT_FAILED | 500 | Failed to capture screenshot |
TIMEOUT | 504 | Request 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'];
}