Show a screenshot (signed link)
A screenshot as an image address, for an <img src>: the options in the query, signed with your signing secret, so it needs no key and nobody can change it. Rendered on its first view, answered from the cache after.
Authentication
The signature, made with the signing secret of the key that key_id names (Authentication). Views count toward a limit of their own, 120 a minute from each visitor's address, not your requests per minute. A link with a wrong signature counts nothing.
Request
The options come first, in any order, then key_id, then signature, last. Booleans are true, false, 1 or 0, in lower case; numbers are digits; each option at most once.
| Query parameter | Description |
|---|---|
urlstringrequired | The page, http or https, up to 2,048 characters. |
viewport_widthintegeroptional | The browser window's width, 320 to 3,840. Default: |
viewport_heightintegeroptional | The browser window's height, 200 to 4,320. With both |
device_scale_factorintegeroptional |
|
full_pagebooleanoptional |
|
formatstringoptional |
|
qualityintegeroptional | 1 to 100, for |
widthintegeroptional | The image resized to this width, 16 to 3,840: a thumbnail. Alone, it keeps the capture's proportions. Default: none, the capture's width. |
heightintegeroptional | The image resized to this height, 16 to 16,383. With |
delayintegeroptional | Seconds to wait after the page has loaded, 0 to 10. Default: |
wait_untilstringoptional | When the page counts as loaded: |
wait_for_selectorstringoptional | A CSS selector to wait for before the capture, up to 255 characters. If it doesn't appear in 30 seconds, the render fails as a timeout. Default: none. |
block_cookie_bannersbooleanoptional | Answers the page's cookie banner as a visitor would, rejecting, so the capture has no banner. Default: |
block_adsbooleanoptional | Blocks ads and trackers. Default: |
dark_modebooleanoptional | Asks the page for its dark theme ( |
user_agentstringoptional | The browser's User-Agent, up to 512 printable characters. PagePeeker's robot signature is added at its end. Default: Chrome's. |
accept_languagestringoptional | The languages the browser asks for, as |
cache_ttlintegeroptional | How old a cached render may be to be answered, in seconds, 86,400 to 2,592,000 (a day to 30 days): a signed link takes no less than a day. Default: |
| Query parameter | Description |
|---|---|
key_idstringrequired | The first 8 characters of your API key, after the options. |
signaturestringrequired | Last: the HMAC-SHA256, in hex, of everything before |
Not taken: wait and fresh (anyone who has the link could make every view a new render).
Response
Always something an <img> can show, never JSON:
| Answer | When |
|---|---|
302 to the image | The render is in the cache, or was done within 30 seconds. The redirect may be cached for what is left of cache_ttl. It carries the limit headers, for this visitor's minute. |
200, a "being rendered" PNG, 640 x 480 | The render wasn't done in 30 seconds. Not cached: the next view gets the render. |
200, a "not available" PNG, 640 x 480, with X-PP-Error-Code | The page couldn't be rendered (the header has the reason), or the link was refused (it has the error code: invalid_signature, invalid_option, rate_limited, over_quota and so on). Not cached. |
Status codes
| Status | Answer | When |
|---|---|---|
| 302 | Redirect to the image | Done. |
| 200 | An image of ours | Not done in 30 seconds, failed, or refused: see the response. |
Every endpoint can also answer 403 https_required, 405 method_not_allowed, 500 internal_error. What each error means and what to do about it: Errors and failures.
Example
import hashlib, hmac
from urllib.parse import urlencode
KEY_ID = "pp_4kT9z" # the first 8 characters of your API key
SECRET = "YOUR_SIGNING_SECRET"
def signed_link(options):
query = urlencode(options) + "&key_id=" + KEY_ID
signature = hmac.new(SECRET.encode(), query.encode(), hashlib.sha256).hexdigest()
return "https://api.pagepeeker.com/v3/shot?" + query + "&signature=" + signature
print(signed_link({"url": "https://www.python.org/", "width": 480, "height": 360}))
<?php
const KEY_ID = 'pp_4kT9z'; // the first 8 characters of your API key
const SECRET = 'YOUR_SIGNING_SECRET';
function signed_link(array $options): string
{
$query = http_build_query($options) . '&key_id=' . KEY_ID;
return 'https://api.pagepeeker.com/v3/shot?' . $query . '&signature=' . hash_hmac('sha256', $query, SECRET);
}
echo signed_link(['url' => 'https://www.python.org/', 'width' => 480, 'height' => 360]);
import { createHmac } from "node:crypto";
const KEY_ID = "pp_4kT9z"; // the first 8 characters of your API key
const SECRET = "YOUR_SIGNING_SECRET";
function signedLink(options) {
const query = new URLSearchParams(options).toString() + "&key_id=" + KEY_ID;
const signature = createHmac("sha256", SECRET).update(query).digest("hex");
return "https://api.pagepeeker.com/v3/shot?" + query + "&signature=" + signature;
}
console.log(signedLink({ url: "https://www.python.org/", width: 480, height: 360 }));
# The query, then its HMAC-SHA256 with your signing secret
QUERY='url=https%3A%2F%2Fwww.python.org%2F&width=480&height=360&key_id=pp_4kT9z'
SIGNATURE=$(printf %s "$QUERY" | openssl dgst -sha256 -hmac 'YOUR_SIGNING_SECRET' | awk '{print $NF}')
# What a browser gets for it: -i shows the redirect to the image
curl -i "https://api.pagepeeker.com/v3/shot?$QUERY&signature=$SIGNATURE"
With the signing secret YOUR_SIGNING_SECRET, that makes this link:
https://api.pagepeeker.com/v3/shot?url=https%3A%2F%2Fwww.python.org%2F&width=480&height=360&key_id=pp_4kT9z&signature=be3aac34adfde1aa1e0e743d42d883d9ea301de9fa6d29e6ff8d2f652823ad75
How to use them in pages, who can use a link and what a view costs: Signed links.