Skip to navigation

Pagination

Page through every listing with page[number] and page[size]

View as MarkdownOpen in Claude

Every listing is paginated. Choose the page and its size with two query parameters:

ParameterDefaultAllowed
page[number]11 or more
page[size]151 to 50

A page[size] above 50 answers 422 rather than being reduced.

curl "https://api.modulards.com/api/public/v1/sites?page[number]=2&page[size]=50" \
-H "Authorization: Bearer $MODULAR_DS_TOKEN"

The response

A paginated response carries links to the neighbouring pages and a meta block describing the page:

{
"data": [ ... ],
"links": {
"first": "https://api.modulards.com/api/public/v1/sites?page[number]=1&page[size]=50",
"last": "https://api.modulards.com/api/public/v1/sites?page[number]=3&page[size]=50",
"prev": "https://api.modulards.com/api/public/v1/sites?page[number]=1&page[size]=50",
"next": "https://api.modulards.com/api/public/v1/sites?page[number]=3&page[size]=50"
},
"meta": {
"current_page": 2,
"from": 51,
"last_page": 3,
"path": "https://api.modulards.com/api/public/v1/sites",
"per_page": 50,
"to": 100,
"total": 128
},
"jsonapi": { "version": "1.1" }
}

links.prev is null on the first page and links.next is null on the last one. The links keep your page[size].

Walking a whole listing

Keep every filter, sort and page[size] fixed, and follow links.next until it is null. Equivalently, advance page[number] until meta.current_page reaches meta.last_page.

meta.total counts the rows of that listing, which is not always a number of websites: a listing of backups counts backups.

If you create or delete resources while you walk, rows can shift between pages. Finish reading before you change what the listing selects.