Pagination
List endpoints return paginated results to efficiently handle large datasets.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number (1-indexed) |
page_size | integer | 50 | Number of items per page (max 100) |
Example Request
bash
curl -X GET "https://api.mentium.io/v2/tms-api/locations?page=2&page_size=25" \
-H "X-API-Key: your_api_key_here"Response Format
Paginated responses include metadata about the pagination:
json
{
"items": [
{ "id": "...", "name": "Location 1" },
{ "id": "...", "name": "Location 2" }
],
"pagination": {
"page": 2,
"page_size": 25,
"total_items": 150,
"total_pages": 6,
"has_next": true,
"has_previous": true
}
}Iterating Through All Pages
python
def get_all_locations(api_key):
all_locations = []
page = 1
while True:
response = requests.get(
f"https://api.mentium.io/v2/tms-api/locations?page={page}&page_size=100",
headers={"X-API-Key": api_key}
)
data = response.json()
all_locations.extend(data["items"])
if not data["pagination"]["has_next"]:
break
page += 1
return all_locationsjavascript
async function getAllLocations(apiKey) {
const allLocations = [];
let page = 1;
let hasNext = true;
while (hasNext) {
const response = await fetch(
`https://api.mentium.io/v2/tms-api/locations?page=${page}&page_size=100`,
{ headers: { "X-API-Key": apiKey } }
);
const data = await response.json();
allLocations.push(...data.items);
hasNext = data.pagination.has_next;
page++;
}
return allLocations;
}Best Practices
TIP
Use a reasonable page_size (50-100) to balance between fewer requests and response size.
WARNING
Don't assume the total count won't change between pages. New items may be added or removed during pagination.