Pagination
How to paginate through list endpoints.
Overview
List endpoints use offset-based pagination. You control the page size and position using query parameters.
Query parameters
| Parameter | Type | Description |
|---|---|---|
page | integer | Page number (1-based). Defaults to 1. |
limit | integer | Number of items per page. Defaults to 50, maximum 100. |
sort_by | string | Field to sort by. Allowed values: created_at, updated_at, name, scheduled_at, published_at, last_used_at, status, file_name. Defaults to created_at. |
sort_dir | string | "asc" or "desc". Defaults to "desc". |
Response format
All list endpoints return a consistent response shape with a pagination object:
Response
{
"success": true,
"data": [
{ "id": "abc123", ... },
{ "id": "def456", ... }
],
"pagination": {
"page": 1,
"limit": 50,
"has_more": true
}
}| Parameter | Type | Description |
|---|---|---|
success* | boolean | Always true for successful responses. |
data* | array | The list of items for the current page. |
pagination.page* | integer | The current page number. |
pagination.limit* | integer | The number of items per page. |
pagination.has_more* | boolean | Whether there are more pages after the current one. |
Example: paginating through all content items
JavaScript
async function getAllContentItems(brandId) {
const allContentItems = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const response = await fetch(
`https://api.wahlu.com/v1/brands/${brandId}/content-items?page=${page}&limit=100`,
{
headers: {
Authorization: "Bearer wahlu_live_your_api_key_here",
},
}
);
const body = await response.json();
allContentItems.push(...body.data);
hasMore = body.pagination.has_more;
page++;
}
return allContentItems;
}