Pagination
How to paginate large result sets using the TournamentSuite API.
List endpoints return paginated results. Use the page and limit query parameters to navigate through result sets.
Query parameters
| Parameter | Type | Default | Maximum | Description |
|---|---|---|---|---|
page | integer | 1 | — | Page number (1-based) |
limit | integer | 10 | 100 | Number of items per page |
Example request
curl "https://api.tournamentsuite.com/api/v1/tournaments?page=2&limit=20" \
-H "X-API-Key: YOUR_API_KEY"Pagination object
Every list response includes a pagination object:
{
"success": true,
"data": [...],
"pagination": {
"page": 2,
"limit": 20,
"total": 150,
"totalPages": 8,
"hasNext": true,
"hasPrevious": true
}
}| Field | Description |
|---|---|
page | Current page number |
limit | Items returned per page |
total | Total number of items across all pages |
totalPages | Total number of pages |
hasNext | Whether a next page exists |
hasPrevious | Whether a previous page exists |
Iterating all pages
async function fetchAllTournaments(apiKey: string) {
const results = [];
let page = 1;
let hasNext = true;
while (hasNext) {
const response = await fetch(
`https://api.tournamentsuite.com/api/v1/tournaments?page=${page}&limit=100`,
{ headers: { 'X-API-Key': apiKey } }
);
const json = await response.json();
results.push(...json.data);
hasNext = json.pagination.hasNext;
page++;
}
return results;
}