Get started
Quickstart
Get your first screenshot from your server in a few minutes. You need a PagePeeker account.
1
Get your API key
In your account, open API key. Every call sends it as code.
WarningKeep your code on your server. Anyone who copies it can spend your monthly API calls.
2
Request a capture
Set size to one of the five standard sizes and url to the page you want. The first call to thumbs_ready.php starts the render. Repeat it until IsReady is 1, then download the image from thumbs.php with the same parameters. Each check counts as one API call, so leave a few seconds between them.
import requests, time
API = "https://api.pagepeeker.com/v2"
params = {"size": "l", "code": "YOUR_CODE", "url": "https://example.org/"}
for attempt in range(24):
status = requests.get(f"{API}/thumbs_ready.php", params=params).json()
if status["IsReady"] or status["Error"]:
break
time.sleep(5)
if status["IsReady"]:
image = requests.get(f"{API}/thumbs.php", params=params)
with open("capture.jpg", "wb") as f:
f.write(image.content)
$api = "https://api.pagepeeker.com/v2";
$query = http_build_query(["size" => "l", "code" => "YOUR_CODE", "url" => "https://example.org/"]);
for ($attempt = 0; $attempt < 24; $attempt++) {
$status = json_decode(file_get_contents("$api/thumbs_ready.php?$query"), true);
if ($status["IsReady"] || $status["Error"]) {
break;
}
sleep(5);
}
if ($status["IsReady"]) {
file_put_contents("capture.jpg", file_get_contents("$api/thumbs.php?$query"));
}
import { writeFile } from "node:fs/promises";
import { setTimeout as sleep } from "node:timers/promises";
const api = "https://api.pagepeeker.com/v2";
const query = new URLSearchParams({ size: "l", code: "YOUR_CODE", url: "https://example.org/" });
let status;
for (let attempt = 0; attempt < 24; attempt++) {
status = await (await fetch(`${api}/thumbs_ready.php?${query}`)).json();
if (status.IsReady || status.Error) break;
await sleep(5000);
}
if (status.IsReady) {
const image = await fetch(`${api}/thumbs.php?${query}`);
await writeFile("capture.jpg", Buffer.from(await image.arrayBuffer()));
}
# Starts the render. Repeat until IsReady is 1
curl "https://api.pagepeeker.com/v2/thumbs_ready.php?size=l&code=YOUR_CODE&url=example.org"
# Then download the capture
curl -o capture.jpg "https://api.pagepeeker.com/v2/thumbs.php?size=l&code=YOUR_CODE&url=example.org"
NoteCheck before you download. For a URL with no capture yet,
thumbs.php returns a placeholder image with status 200.3
Handle the answers
thumbs_ready.php answers in JSON. When Error is 1, stop checking: Errors explains why.
// Still rendering
{"IsReady":0,"Error":0}
// Ready to download
{"IsReady":1,"Error":0}
// The page could not be captured
{"IsReady":0,"Error":1}