Screenshot API Code Examples
Copy-paste ready code examples in cURL, JavaScript, Python, PHP, Ruby, and Go. Get started capturing screenshots in minutes.
API Endpoint
GET https://api.rasterwise.com/v1/get-screenshot
Response
{
"status": "success",
"originUrl": "https://example.com",
"pageStatus": 200,
"captureDate": "2026/11/18",
"captureHour": "14:03:22",
"aiAnalysis": null,
"screenshotImage": "https://storage.googleapis.com/getscreenshot-storage/imageAbC123xYz9.png"
}
Every response is JSON. The API does not return image bytes and does not redirect to the image. Read screenshotImage (or pdfFile when you pass pdf=true) and download the file from that URL. Files are stored for 30 days. Authentication is the apikey query parameter; there is no header auth.
Typical captures take 8–15 seconds and a request can take up to 90 seconds, so set your HTTP client timeout to at least 90 seconds. Every authenticated request uses one screenshot from your monthly quota, including captures that fail.
Using an AI agent? Point it at /llms.txt or /openapi.yaml, or give it the MCP server described on the AI Agents page.
Basic Screenshot
The simplest API call - just provide your API key and the URL to capture.
curl -G "https://api.rasterwise.com/v1/get-screenshot" \
--data-urlencode "apikey=YOUR_API_KEY" \
--data-urlencode "url=https://example.com"
const apiKey = 'YOUR_API_KEY';
const targetUrl = 'https://example.com';
const params = new URLSearchParams({
apikey: apiKey,
url: targetUrl
});
const response = await fetch(
`https://api.rasterwise.com/v1/get-screenshot?${params}`
);
const data = await response.json();
console.log(data.screenshotImage); // URL to screenshot
import requests
api_key = 'YOUR_API_KEY'
target_url = 'https://example.com'
response = requests.get(
'https://api.rasterwise.com/v1/get-screenshot',
params={
'apikey': api_key,
'url': target_url
}
)
data = response.json()
print(data['screenshotImage']) # URL to screenshot
<?php
$apiKey = 'YOUR_API_KEY';
$targetUrl = 'https://example.com';
$params = http_build_query([
'apikey' => $apiKey,
'url' => $targetUrl
]);
$response = file_get_contents(
"https://api.rasterwise.com/v1/get-screenshot?{$params}"
);
$data = json_decode($response, true);
echo $data['screenshotImage']; // URL to screenshot
require 'net/http'
require 'json'
require 'uri'
api_key = 'YOUR_API_KEY'
target_url = 'https://example.com'
uri = URI('https://api.rasterwise.com/v1/get-screenshot')
uri.query = URI.encode_www_form({
apikey: api_key,
url: target_url
})
response = Net::HTTP.get(uri)
data = JSON.parse(response)
puts data['screenshotImage'] # URL to screenshot
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
func main() {
apiKey := "YOUR_API_KEY"
targetUrl := "https://example.com"
params := url.Values{}
params.Add("apikey", apiKey)
params.Add("url", targetUrl)
resp, _ := http.Get(
"https://api.rasterwise.com/v1/get-screenshot?" + params.Encode(),
)
defer resp.Body.Close()
var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
fmt.Println(data["screenshotImage"])
}
Full Page Screenshot
Capture the entire scrollable length of a webpage with fullpage=true.
curl -G "https://api.rasterwise.com/v1/get-screenshot" \
--data-urlencode "apikey=YOUR_API_KEY" \
--data-urlencode "url=https://example.com/long-page" \
--data-urlencode "fullpage=true" \
--data-urlencode "width=1280"
const params = new URLSearchParams({
apikey: 'YOUR_API_KEY',
url: 'https://example.com/long-page',
fullpage: 'true',
width: '1280'
});
const response = await fetch(
`https://api.rasterwise.com/v1/get-screenshot?${params}`
);
const data = await response.json();
// data.screenshotImage contains the full page screenshot
import requests
response = requests.get(
'https://api.rasterwise.com/v1/get-screenshot',
params={
'apikey': 'YOUR_API_KEY',
'url': 'https://example.com/long-page',
'fullpage': 'true',
'width': '1280'
}
)
data = response.json()
# data['screenshotImage'] contains the full page screenshot
PDF Generation
Generate a PDF document from any webpage with pdf=true. The response contains pdfFile instead of screenshotImage. PDFs use A4 pages.
curl -G "https://api.rasterwise.com/v1/get-screenshot" \
--data-urlencode "apikey=YOUR_API_KEY" \
--data-urlencode "url=https://example.com/article" \
--data-urlencode "pdf=true"
const params = new URLSearchParams({
apikey: 'YOUR_API_KEY',
url: 'https://example.com/article',
pdf: 'true'
});
const response = await fetch(
`https://api.rasterwise.com/v1/get-screenshot?${params}`
);
const data = await response.json();
console.log(data.pdfFile); // URL to PDF file
import requests
response = requests.get(
'https://api.rasterwise.com/v1/get-screenshot',
params={
'apikey': 'YOUR_API_KEY',
'url': 'https://example.com/article',
'pdf': 'true'
}
)
data = response.json()
print(data['pdfFile']) # URL to PDF file
Custom Viewport Size
Capture mobile, tablet, or custom dimensions with width and height. Set the pixel density with devicefactor.
# iPhone 14 viewport
curl -G "https://api.rasterwise.com/v1/get-screenshot" \
--data-urlencode "apikey=YOUR_API_KEY" \
--data-urlencode "url=https://example.com" \
--data-urlencode "width=390" \
--data-urlencode "height=844" \
--data-urlencode "devicefactor=3"
// iPhone 14 viewport
const params = new URLSearchParams({
apikey: 'YOUR_API_KEY',
url: 'https://example.com',
width: '390',
height: '844',
devicefactor: '3' // Retina 3x
});
const response = await fetch(
`https://api.rasterwise.com/v1/get-screenshot?${params}`
);
# iPhone 14 viewport
import requests
response = requests.get(
'https://api.rasterwise.com/v1/get-screenshot',
params={
'apikey': 'YOUR_API_KEY',
'url': 'https://example.com',
'width': '390',
'height': '844',
'devicefactor': '3' # Retina 3x
}
)
Element Screenshot
Capture a specific element using a CSS selector with element. A selector that matches nothing makes the request fail with HTTP 500, so check the selector on the live page first.
# Capture just the main article content
curl -G "https://api.rasterwise.com/v1/get-screenshot" \
--data-urlencode "apikey=YOUR_API_KEY" \
--data-urlencode "url=https://example.com/blog-post" \
--data-urlencode "element=article.main-content"
// Capture just the main article content
const params = new URLSearchParams({
apikey: 'YOUR_API_KEY',
url: 'https://example.com/blog-post',
element: 'article.main-content'
});
const response = await fetch(
`https://api.rasterwise.com/v1/get-screenshot?${params}`
);
# Capture just the main article content
import requests
response = requests.get(
'https://api.rasterwise.com/v1/get-screenshot',
params={
'apikey': 'YOUR_API_KEY',
'url': 'https://example.com/blog-post',
'element': 'article.main-content'
}
)
Hide Elements
Hide unwanted elements like ads or popups with hideelement. Add hidemsg=true to hide common chat widgets. Cookie banners are hidden by default; pass hidecookie=false to keep them.
# Hide ads, popups, and chat widgets
curl -G "https://api.rasterwise.com/v1/get-screenshot" \
--data-urlencode "apikey=YOUR_API_KEY" \
--data-urlencode "url=https://example.com" \
--data-urlencode "hideelement=.ads, #popup" \
--data-urlencode "hidemsg=true"
// Hide ads, popups, and chat widgets
const params = new URLSearchParams({
apikey: 'YOUR_API_KEY',
url: 'https://example.com',
hideelement: '.ads, #popup',
hidemsg: 'true'
});
const response = await fetch(
`https://api.rasterwise.com/v1/get-screenshot?${params}`
);
# Hide ads, popups, and chat widgets
import requests
response = requests.get(
'https://api.rasterwise.com/v1/get-screenshot',
params={
'apikey': 'YOUR_API_KEY',
'url': 'https://example.com',
'hideelement': '.ads, #popup',
'hidemsg': 'true'
}
)
Custom JavaScript Injection
Run JavaScript on the page before capturing with the customjs parameter. Use timewait to give the page time to update. To inject CSS instead, use customcss.
# Click "Accept cookies" and expand collapsed sections
curl -G "https://api.rasterwise.com/v1/get-screenshot" \
--data-urlencode "apikey=YOUR_API_KEY" \
--data-urlencode "url=https://example.com" \
--data-urlencode "customjs=document.querySelector('.accept-cookies')?.click(); document.querySelectorAll('.expand-btn').forEach(b => b.click());" \
--data-urlencode "timewait=2000"
// Click "Accept cookies" and expand collapsed sections
const customJs = `
document.querySelector('.accept-cookies')?.click();
document.querySelectorAll('.expand-btn').forEach(b => b.click());
`;
const params = new URLSearchParams({
apikey: 'YOUR_API_KEY',
url: 'https://example.com',
customjs: customJs,
timewait: '2000' // Wait 2s for animations
});
const response = await fetch(
`https://api.rasterwise.com/v1/get-screenshot?${params}`
);
# Click "Accept cookies" and expand collapsed sections
import requests
custom_js = """
document.querySelector('.accept-cookies')?.click();
document.querySelectorAll('.expand-btn').forEach(b => b.click());
"""
response = requests.get(
'https://api.rasterwise.com/v1/get-screenshot',
params={
'apikey': 'YOUR_API_KEY',
'url': 'https://example.com',
'customjs': custom_js,
'timewait': '2000' # Wait 2s for animations
}
)
Wait Options
Control when to capture with waituntil and timewait. Longer waits make the request slower; the whole request has to finish within 90 seconds.
# Wait for network to be completely idle, plus 3 extra seconds
curl -G "https://api.rasterwise.com/v1/get-screenshot" \
--data-urlencode "apikey=YOUR_API_KEY" \
--data-urlencode "url=https://example.com/dashboard" \
--data-urlencode "waituntil=networkidle0" \
--data-urlencode "timewait=3000"
// Wait for network to be completely idle, plus 3 extra seconds
const params = new URLSearchParams({
apikey: 'YOUR_API_KEY',
url: 'https://example.com/dashboard',
waituntil: 'networkidle0', // Or: networkidle2, domcontentloaded, load
timewait: '3000' // Additional 3s wait
});
const response = await fetch(
`https://api.rasterwise.com/v1/get-screenshot?${params}`
);
| waituntil Value | Description |
|---|---|
| load | Wait for the load event |
| domcontentloaded | Wait for the DOMContentLoaded event. Fastest, and the most reliable choice on heavy sites |
| networkidle2 | Wait until there are no more than 2 network connections for 500ms (default) |
| networkidle0 | Wait until no network connections for 500ms (strictest) |
API Parameters Reference
The most used parameters. All names are lowercase.
| Parameter | Type | Description |
|---|---|---|
| apikey | string | Your API key (required) |
| url | string | URL to capture (required) |
| width | number | Viewport width in pixels (default: 1280) |
| height | number | Viewport height in pixels (default: 800) |
| fullpage | boolean | Capture the entire scrollable page (default: false) |
| format | string | Image format: png or jpeg (default: png) |
| boolean | Return an A4 PDF (pdfFile) instead of an image |
|
| element | string | CSS selector; captures only that element |
| hideelement | string | CSS selectors to hide (comma-separated) |
| hidecookie | boolean | Hide common cookie banners (default: true). Pass false to keep them |
| hidemsg | boolean | Hide common chat widgets (default: false) |
| customjs | string | JavaScript to execute before capture |
| customcss | string | CSS to inject before capture |
| waituntil | string | When to consider the page loaded: load, domcontentloaded, networkidle0, networkidle2 (default) |
| timewait | number | Extra wait in ms before capture (default: 2000) |
| devicefactor | number | Device pixel ratio (default: 1; 2 for retina) |
Ready to Start Capturing Screenshots?
Get your API key and start capturing screenshots in minutes. Plans start at $5/month with 2,500 screenshots included.