API Reference
Pagination
Every list endpoint in the Pineprompt API paginates its results using a shared envelope. Pagination is page-number-based, with an optional per_page parameter to control the size of each page.
Query parameters
You may control pagination using two query parameters. Both are optional.
| Name | Type | Required | Description |
|---|---|---|---|
| per_page | integer | Optional | The number of items to return on each page. Defaults to 25, with a minimum of 1 and a maximum of 100. Values outside this range are silently clamped. |
| page | integer | Optional | The page number to return, starting at |
The response envelope
Every paginated response carries the records under data, alongside links and meta for navigation:
{
"data": [ /* records */ ],
"links": {
"first": "https://pineprompt.com/api/v1/monitors?page=1",
"last": "https://pineprompt.com/api/v1/monitors?page=3",
"prev": null,
"next": "https://pineprompt.com/api/v1/monitors?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 3,
"path": "https://pineprompt.com/api/v1/monitors",
"per_page": 25,
"to": 25,
"total": 72
}
}
Pagination links
The links object carries the absolute URLs you should follow to move between pages. Each is null when there is no such page.
| Field | Type | Description |
|---|---|---|
| first | string | The URL of the first page, or |
| last | string | The URL of the last page, or |
| prev | string | The URL of the previous page, or |
| next | string | The URL of the next page, or |
Pagination metadata
The meta object describes the page you received and the collection as a whole.
| Field | Type | Description |
|---|---|---|
| current_page | integer | The page number you are currently viewing, starting at |
| from | integer | The index of the first record on this page within the full collection, or |
| last_page | integer | The number of the final page. |
| path | string | The base URL of the endpoint, without any query string. |
| per_page | integer | The number of records requested per page. |
| to | integer | The index of the last record on this page within the full collection, or |
| total | integer | The exact number of records across every page. |
| links | PaginationLink[] | The page-link rows, in display order from the first page through the last. The set always opens with a previous link and closes with a next link. |
Pagination link
Each entry in meta.links describes a single page link, ready to render as a paginator control.
| Field | Type | Description |
|---|---|---|
| url | string | The URL for this link, or |
| label | string | The label for this link, either a page number or a localized previous or next caption. |
| page | integer | The page number this link points to, or |
| active | boolean | Whether this link is the page currently being returned. |
Walking every page
Typically, the simplest way to iterate every record is to follow links.next until it becomes null:
Example
async function* paginate(url, headers) {
let next = url;
while (next) {
const response = await fetch(next, { headers });
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const payload = await response.json();
yield* payload.data;
next = payload.links.next;
}
}
const headers = {
"Authorization": `Bearer ${process.env.PINEPROMPT_TOKEN}`,
"Pineprompt-Project-Id": "42",
};
for await (const monitor of paginate("https://pineprompt.com/api/v1/monitors?per_page=100", headers)) {
console.log(monitor.id);
}
import os, requests
headers = {
"Authorization": f"Bearer {os.environ['PINEPROMPT_TOKEN']}",
"Pineprompt-Project-Id": "42",
}
url = "https://pineprompt.com/api/v1/monitors?per_page=100"
while url:
response = requests.get(url, headers=headers)
response.raise_for_status()
payload = response.json()
for monitor in payload["data"]:
print(monitor["id"])
url = payload["links"]["next"]
use GuzzleHttp\Client;
$client = new Client();
$url = 'https://pineprompt.com/api/v1/monitors?per_page=100';
$headers = [
'Authorization' => 'Bearer '.getenv('PINEPROMPT_TOKEN'),
'Pineprompt-Project-Id' => '42',
];
while ($url) {
$response = $client->get($url, ['headers' => $headers]);
$payload = json_decode((string) $response->getBody(), true);
foreach ($payload['data'] as $monitor) {
echo $monitor['id'].PHP_EOL;
}
$url = $payload['links']['next'] ?? null;
}
A few notes
- For bulk backfills, you should set
per_page=100. Larger pages mean fewer round-trips, and the rate-limit cost is identical regardless of page size. - The
meta.totalfield is an exact total. On very large collections, computing it carries a cost, so if you only need to walk the list, you may safely ignore it. - The non-paginated
projectsarray inside GET /me is the only collection that does not use this envelope.