Pagination
In this guide, we will look at how to work with paginated responses when querying the Mobile API. By default, all responses limit results to fifteen.
In responses, objects are nested in a data attribute. For paginated responses, there is a links and meta attribute which contains data and links regarding the pagination. You can use the page query parameters to browse pages.
Example using cursors
In this example, we request the first page of players. As a result, we get a list of fifteen players and can tell by the links.next attribute that we have more results to load if needed.
- Name
page- Type
- integer
- Description
The page you're currently on.
Manual pagination using cURL
curl -G https://prod-app.themeparkshark.com/api/players \
-H "Accept: application/json" \
-d page=1
Paginated response
{
"data": [
{
"id": 1,
// ...
},
{
"id": 2,
// ...
},
{
"id": 3,
// ...
}
// ...
],
"links": {
"first": "https://prod-app.themeparkshark.com/api/players?page=1",
"last": "https://prod-app.themeparkshark.com/api/players?page=2",
"prev": null,
"next": "https://prod-app.themeparkshark.com/api/players?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"path": "https://prod-app.themeparkshark.com/api/players",
"per_page": 15,
"to": 15
}
}
