All list endpoints in the PageGun API support offset-based pagination.
Query Parameters
| Parameter | Type | Default | Max | Description |
|---|
limit | integer | 20 | 100 | Number of items per page |
offset | integer | 0 | — | Number of items to skip |
Example Request
curl "https://api.pagegun.com/v1/pages?project_id=PROJECT_ID&limit=20&offset=0" \
-H "Authorization: Bearer pgk_live_xxx"
{
"success": true,
"data": [
{ "id": "page_1", "slug": "intro", "..." : "..." },
{ "id": "page_2", "slug": "quick-start", "..." : "..." }
],
"has_more": true,
"total": 42
}
| Field | Type | Description |
|---|
data | array | The items for the current page |
has_more | boolean | true if more items exist beyond this page |
total | integer | Total number of items matching the query |
Iterating All Results
TypeScript
async function fetchAllPages(projectId: string) {
const allPages = []
let offset = 0
const limit = 100
while (true) {
const res = await fetch(
`https://api.pagegun.com/v1/pages?project_id=${projectId}&limit=${limit}&offset=${offset}`,
{ headers: { 'Authorization': 'Bearer pgk_live_xxx' } }
)
const json = await res.json()
allPages.push(...json.data)
if (!json.has_more) break
offset += limit
}
return allPages
}
curl + jq
OFFSET=0
LIMIT=100
while true; do
RESPONSE=$(curl -s "https://api.pagegun.com/v1/pages?project_id=PROJECT_ID&limit=$LIMIT&offset=$OFFSET" \
-H "Authorization: Bearer pgk_live_xxx")
echo "$RESPONSE" | jq '.data[]'
HAS_MORE=$(echo "$RESPONSE" | jq '.has_more')
[ "$HAS_MORE" = "false" ] && break
OFFSET=$((OFFSET + LIMIT))
done