Pagination¶
Although, pagination of resources is not strictly defined in JSON:API, we chose to follow one of the recommendations for the "page-based" strategy. The query parameters being used are:
page[number]page[size]
So let's take an example resource named Book. Here's an example of how
this resource could be paginated:
GET /books/?page[number]=1&page[size]=2
curl \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "Accept: application/vnd.api+json" \
"https://api.socialwifi.com/examples/books/?page\[number\]=1&page\[size\]=2" \
| jq
Example response
{
"data": [
{
"type": "books",
"id": "1"
},
{
"type": "books",
"id": "2"
}
],
"links": {
"self": "https://api.socialwifi.com/examples/books/?page[number]=1&page[size]=2",
"first": "https://api.socialwifi.com/examples/books/?page[number]=1&page[size]=2",
"previous": null,
"next": "https://api.socialwifi.com/examples/books/?page[number]=2&page[size]=2",
"last": "https://api.socialwifi.com/examples/books/?page[number]=50&page[size]=2"
},
"meta": {
"count": 2
},
"jsonapi": {
"version": "1.0"
}
}
Info
When an endpoint supports pagination, it's explicitly mentioned in the documentation.