Screenshots
Ask for a screenshot, wait for it or ask again later, and download the image.
The whole flow
Ask for the screenshot with wait, so most renders come back in the same request. If it isn't done in that time, ask again with its id every few seconds. Over the rate limit, wait the seconds of Retry-After and try again. A refused request (an error, see Errors and failures) or a failed render ends it. Then download the image.
import time
import requests
API = "https://api.pagepeeker.com/v3"
HEADERS = {"Authorization": "Bearer YOUR_KEY"}
# One call to the API. Over the rate limit, it waits as told and tries again.
def call(method, path, body=None):
while True:
res = requests.request(method, API + path, headers=HEADERS, json=body)
if res.status_code != 429:
break
time.sleep(int(res.headers["Retry-After"]))
answer = res.json()
if "error" in answer: # refused: see Errors and failures
raise RuntimeError(answer["error"]["code"] + ": " + answer["error"]["message"])
return answer
# Ask for the screenshot, holding the request open up to 30 seconds.
shot = call("POST", "/shot", {
"url": "https://example.com/",
"width": 480,
"height": 360,
"wait": 30,
})
# Not done in 30 seconds: ask again every 5 seconds.
while shot["status"] == "queued":
time.sleep(5)
shot = call("GET", "/shot/" + shot["id"])
if shot["status"] == "failed":
raise RuntimeError(shot["reason"] + ": " + shot["message"])
# Done: download the image. Its address needs no key.
with open("capture.jpg", "wb") as f:
f.write(requests.get(shot["url"]).content)
<?php
const API = 'https://api.pagepeeker.com/v3';
const KEY = 'YOUR_KEY';
// One call to the API. Over the rate limit, it waits as told and tries again.
function call(string $method, string $path, ?array $body = null): array
{
while (true) {
$retryAfter = 1;
$options = [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . KEY, 'Content-Type: application/json'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADERFUNCTION => function ($http, $line) use (&$retryAfter) {
if (stripos($line, 'Retry-After:') === 0) {
$retryAfter = (int) substr($line, 12);
}
return strlen($line);
},
];
if ($body !== null) {
$options[CURLOPT_POSTFIELDS] = json_encode($body);
}
$http = curl_init(API . $path);
curl_setopt_array($http, $options);
$answer = json_decode(curl_exec($http), true);
if (curl_getinfo($http, CURLINFO_RESPONSE_CODE) != 429) {
break;
}
sleep($retryAfter);
}
if (isset($answer['error'])) { // refused: see Errors and failures
throw new RuntimeException($answer['error']['code'] . ': ' . $answer['error']['message']);
}
return $answer;
}
// Ask for the screenshot, holding the request open up to 30 seconds.
$shot = call('POST', '/shot', [
'url' => 'https://example.com/',
'width' => 480,
'height' => 360,
'wait' => 30,
]);
// Not done in 30 seconds: ask again every 5 seconds.
while ($shot['status'] === 'queued') {
sleep(5);
$shot = call('GET', '/shot/' . $shot['id']);
}
if ($shot['status'] === 'failed') {
throw new RuntimeException($shot['reason'] . ': ' . $shot['message']);
}
// Done: download the image. Its address needs no key.
file_put_contents('capture.jpg', file_get_contents($shot['url']));
import { writeFile } from "node:fs/promises";
const API = "https://api.pagepeeker.com/v3";
const HEADERS = { Authorization: "Bearer YOUR_KEY", "Content-Type": "application/json" };
const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
// One call to the API. Over the rate limit, it waits as told and tries again.
async function call(method, path, body) {
while (true) {
const res = await fetch(API + path, { method, headers: HEADERS, body: body ? JSON.stringify(body) : undefined });
if (res.status === 429) {
await sleep(Number(res.headers.get("Retry-After")));
continue;
}
const answer = await res.json();
if (answer.error) { // refused: see Errors and failures
throw new Error(answer.error.code + ": " + answer.error.message);
}
return answer;
}
}
// Ask for the screenshot, holding the request open up to 30 seconds.
let shot = await call("POST", "/shot", { url: "https://example.com/", width: 480, height: 360, wait: 30 });
// Not done in 30 seconds: ask again every 5 seconds.
while (shot.status === "queued") {
await sleep(5);
shot = await call("GET", "/shot/" + shot.id);
}
if (shot.status === "failed") {
throw new Error(shot.reason + ": " + shot.message);
}
// Done: download the image. Its address needs no key.
const image = await fetch(shot.url);
await writeFile("capture.jpg", Buffer.from(await image.arrayBuffer()));
# Ask for the screenshot, holding the request open up to 30 seconds
curl https://api.pagepeeker.com/v3/shot \
-H "Authorization: Bearer YOUR_KEY" -H "Content-Type: application/json" \
-d '{"url": "https://example.com/", "width": 480, "height": 360, "wait": 30}'
# {"id": "9a3f0c2e5b7d41e8a6c3f2d1e0b9a8c7", "status": "queued"}: not done in 30 seconds
# Ask again every few seconds, with the id
curl https://api.pagepeeker.com/v3/shot/9a3f0c2e5b7d41e8a6c3f2d1e0b9a8c7 \
-H "Authorization: Bearer YOUR_KEY"
# {"id": "9a3f0c2e5b7d41e8a6c3f2d1e0b9a8c7", "status": "done", "url": "https://api.pagepeeker.com/v3/files/9a3f...jpeg", ...}
# Download the image: its address needs no key
curl -o capture.jpg https://api.pagepeeker.com/v3/files/9a3f0c2e5b7d41e8a6c3f2d1e0b9a8c7-4f2a9c1e7b3d5a60.jpeg
# -i on any of them shows the headers: the rate limit and your renders
The request
The body is a JSON object of options, with Content-Type: application/json, and your key in Authorization. Only url is required.
POST /v3/shot HTTP/1.1
Host: api.pagepeeker.com
Authorization: Bearer YOUR_KEY
Content-Type: application/json
{
"url": "https://example.com/",
"full_page": true,
"format": "webp",
"width": 640,
"block_ads": true,
"wait": 30
}
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
RateLimit-Limit: 10
RateLimit-Remaining: 9
RateLimit-Reset: 42
RateLimit-Policy: "minute";q=10;w=60
RateLimit: "minute";r=9;t=42
X-PP-Renders-Used: 124
X-PP-Renders-Limit: 500
{
"id": "5c1e8b0a3f6d42c9b7e1a0d3c5f2e4b6",
"status": "done",
"url": "https://api.pagepeeker.com/v3/files/5c1e8b0a3f6d42c9b7e1a0d3c5f2e4b6-8b2d4f6a1c3e5079.webp",
"rendered_at": "2026-11-16T12:00:00Z",
"final_url": "https://example.com/",
"status_code": 200,
"title": "Example Domain",
"width": 640,
"height": 512,
"bytes": 18420
}
The headers say where you stand: see Limits and usage.
| Answer | Status | When |
|---|---|---|
| done | 200 | A render with these options is in the cache, younger than cache_ttl, or it was done while the request waited. |
| queued | 202 | The render is queued. With wait, it was not done in that time. |
| failed | 200 | The page could not be rendered. The same request is answered as failed for an hour, then rendered again. |
{
"id": "9a3f0c2e5b7d41e8a6c3f2d1e0b9a8c7",
"status": "done",
"url": "https://api.pagepeeker.com/v3/files/9a3f0c2e5b7d41e8a6c3f2d1e0b9a8c7-4f2a9c1e7b3d5a60.jpeg",
"rendered_at": "2026-11-16T12:00:00Z",
"final_url": "https://example.com/",
"status_code": 200,
"title": "Example Domain",
"width": 1280,
"height": 1024,
"bytes": 81234
}
{
"id": "9a3f0c2e5b7d41e8a6c3f2d1e0b9a8c7",
"status": "queued"
}
{
"id": "9a3f0c2e5b7d41e8a6c3f2d1e0b9a8c7",
"status": "failed",
"reason": "timeout",
"message": "The selector did not appear in 30 seconds",
"reason_url": "https://api.pagepeeker.com/v3/reasons/timeout",
"failed_at": "2026-11-16T12:00:00Z"
}
Done
| Field | Meaning |
|---|---|
| id | The render's id. The same options give the same id. |
| url | The image. Its address never changes: a new render of the same page gets a new one. |
| rendered_at | When the render was made, in UTC. |
| final_url | Where the page ended up after redirects. |
| status_code | The HTTP status the page answered with. |
| title | The page's title. |
| width | The image's width, in pixels. |
| height | The image's height, in pixels. |
| bytes | The image's size. |
Failed
reason is a code from Errors and failures, message says what happened in words, and reason_url explains the code.
Asking again
Where a render stands: the same answers as above. 404 not_found for an id that was never asked for, or a failure older than an hour. Each call counts toward your rate limit, so leave a few seconds between them, or use wait.
The image
Download it from url, with no key. It can be cached for good, by you or a browser: the address of a newer render is different. Images are deleted 31 days after they were made, so keep your own copy if you need one longer.
The cache
A request whose options match a render younger than cache_ttl (a day unless you set it) gets that render at once, and costs no render. fresh asks for a new render whatever the cache holds.
cache_ttl, fresh and wait say how to answer, not what to render: they don't change the id.