Getting a fresh capture
Captures renew on their own when your cache time ends. On Premium you can ask for a new one whenever you need it.
When captures renew
A capture stays in the cache for 7 days on Basic, 5 days on Advanced, and as long as you choose on Premium. The first request after that returns the old capture and starts a new render, which replaces it when it's done.
Ask for a new one
Add refresh=1 on a Premium account. To get the new capture in the same response, add wait too: the request stays open until the render is done, or until the time you gave runs out.
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"
Know that it arrived
refresh=1 without wait returns the old capture while the new one renders, and thumbs_ready.php keeps answering IsReady: 1 because a capture is still on file. To tell the two apart, compare the X-PP-Timestamp header: it changes when the new capture replaces the old one.
refresh=1 once, not on every poll. Each one starts another render.