thumbs.php
Returns an image of a page. If there is no capture yet, it starts a render and returns a placeholder right away.
Parameters
| Parameter | Description |
|---|---|
urlrequired | The page to capture, URL encoded. PDF URLs work too and give an image of the first page. IP addresses are refused. |
sizerequired |
|
coderequired | Your API key. Keep it on your server: anyone who sees it can spend your API calls. How accounts are identified covers the one case that goes without it. |
viewportoptional | The browser window to render in, as |
agentoptional | The |
refreshoptionalpremium | Set to |
waitoptionalpremium | The longest to hold the request open for a render, in seconds, from |
What you get back
A status of 200 doesn't always mean the capture you asked for. Use thumbs_ready.php or the headers below when your code needs to know which one it received.
| State | Response | When |
|---|---|---|
| ready | The capture, as an image | A capture exists and is still inside your cache time. |
| queued | A placeholder, or your loading image | This is the first request for this URL and size, and the render is running. |
| stale | The older capture | The capture has expired. A new render is running and will replace it. |
| error | A "Thumbnail not available" image, with X-PP-Error: True | The code is unknown, the account is inactive, or the request could not be matched to an account. X-PP-Error-Message says which. |
| error | A transparent image, with X-PP-Error: True | The page could not be captured. |
Response headers
| Header | Meaning |
|---|---|
| X-PP-Error | True if there was an error, otherwise False. |
| X-PP-Error-Message | Why the request was refused. Only on refused requests. |
| X-PP-Timestamp | When the file served was made, as a Unix timestamp. |
| X-PP-Capture-Time | How long the capture took, in seconds. |
| X-PP-Final-URL | Where the URL ended up after redirects. |
| X-PP-Capture-Method | The engine label, for support. |
| X-PP-Hash | A hash of the URL, for support. |
HTTP/1.1 200 OK
Content-Type: image/jpeg
X-PP-Error: False
X-PP-Timestamp: 1793534000
X-PP-Capture-Time: 3.21
X-PP-Final-URL: https://example.org/
Example
import requests
res = requests.get("https://api.pagepeeker.com/v2/thumbs.php", params={
"size": "x",
"code": "YOUR_CODE",
"refresh": 1,
"wait": 30,
"url": "https://example.org/pricing",
})
print(res.headers["X-PP-Timestamp"])
with open("capture.jpg", "wb") as f:
f.write(res.content)
$query = http_build_query([
"size" => "x",
"code" => "YOUR_CODE",
"refresh" => 1,
"wait" => 30,
"url" => "https://example.org/pricing",
]);
file_put_contents("capture.jpg", file_get_contents("https://api.pagepeeker.com/v2/thumbs.php?" . $query));
import { writeFile } from "node:fs/promises";
const query = new URLSearchParams({
size: "x",
code: "YOUR_CODE",
refresh: "1",
wait: "30",
url: "https://example.org/pricing",
});
const res = await fetch(`https://api.pagepeeker.com/v2/thumbs.php?${query}`);
console.log(res.headers.get("X-PP-Timestamp"));
await writeFile("capture.jpg", Buffer.from(await res.arrayBuffer()));
# Ask for a new capture, wait up to 30 seconds for it, and print the headers
curl -D - -o capture.jpg \
"https://api.pagepeeker.com/v2/thumbs.php?size=x&code=YOUR_CODE&refresh=1&wait=30&url=https%3A%2F%2Fexample.org%2Fpricing"