Authentication
Every call with your key goes from your server, over HTTPS, with the key in a header.
API keys
Make keys on the API keys page of your account, up to 20: one for each app or server, if you like. A key is pp_ and 32 letters and digits. All your keys share your plan's renders and requests per minute.
A key is shown once, when it is made, with its signing secret: they can't be shown again. If you lose a key, revoke it and make a new one. A revoked key stops working within a minute.
Sending the key
| Header | Value |
|---|---|
| Authorization | Bearer YOUR_KEY |
| X-API-Key | YOUR_KEY, if your client can't set Authorization |
Send one of them with every call that needs a key. Header names are not case-sensitive. A key in the URL is not read, and the request is answered 401 missing_key: keys don't belong where logs and browser histories keep them.
HTTPS only
Every call is HTTPS. Plain HTTP is refused with 403 https_required, not redirected: by then the key has already gone out unencrypted, and a redirect would hide that. If it happens, revoke that key.
Check your key
GET /v3/usage needs a key and costs no render, so it makes a good first call. With a working key it answers 200 and your plan's numbers:
import requests
res = requests.get(
"https://api.pagepeeker.com/v3/usage",
headers={"Authorization": "Bearer YOUR_KEY"},
)
print(res.status_code, res.json())
<?php
$http = curl_init('https://api.pagepeeker.com/v3/usage');
curl_setopt_array($http, [
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_KEY'],
CURLOPT_RETURNTRANSFER => true,
]);
$answer = json_decode(curl_exec($http), true);
echo curl_getinfo($http, CURLINFO_RESPONSE_CODE), "\n";
print_r($answer);
const res = await fetch("https://api.pagepeeker.com/v3/usage", {
headers: { Authorization: "Bearer YOUR_KEY" },
});
console.log(res.status, await res.json());
curl -i https://api.pagepeeker.com/v3/usage \
-H "Authorization: Bearer YOUR_KEY"
The signing secret
Each key comes with a signing secret. It signs links that a browser loads without the key: a link carries the key's first 8 characters, its key_id, and a signature made with the secret. Keep the secret on your server too. Revoking the key ends its links.
Endpoints without a key
The images (GET /v3/files/{name}), GET /v3/reasons and GET /v3/ips are public. A signed link is checked by its signature instead of a key.
When authentication fails
| Status | Code | When | What to do |
|---|---|---|---|
| 401 | missing_key | No key in Authorization: Bearer or X-API-Key. A key in the URL is not read. | Send the key in a header: see Authentication. |
| 401 | invalid_key | The key is not valid, or was revoked. | Check it on your API keys page, or make a new one. |
| 403 | account_inactive | The account is not active. | Sign in to see its state, or contact us. |
| 403 | https_required | The request was plain HTTP. | Use https://. The key went out unencrypted: revoke it and make a new one. |
HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8
{
"error": {
"code": "missing_key",
"message": "Send your API key in \"Authorization: Bearer <key>\" or \"X-API-Key: <key>\"."
}
}
These answers carry no limit headers: the request was refused before your limits were looked at, and it isn't counted.