Pagination
When querying the Cocktail API, responses are paginated to manage large datasets efficiently. By default, each response limits results to 10 items. You can increase this limit up to 100 items per page by using the page_size parameter in your requests. If you’re using one of the API client libraries, pagination is handled automatically for you.
Pagination Parameters
- Name
page
- Type
- string
- Description
Specifies the page number to retrieve. The default is 1.
- Name
page_size
- Type
- integer
- Description
Specifies the number of items per page. The default is 10, with a maximum of 100.
- Name
count
- Type
- string
- Description
The total number of items available.
- Name
next
- Type
- integer
- Description
URL to retrieve the next page of results.
- Name
previous
- Type
- integer
- Description
URL to retrieve the previous page of results.
- Name
results
- Type
- integer
- Description
Array of items on the current page.
Response Structure
In paginated responses, data is provided in the results attribute. The response also includes metadata to help navigate through pages:
Manual pagination using cURL
curl -G "https://<your-deployment-url>/api/cocktails/" \
-H "Authorization: Token your_token_here" \
-d page=2 \
-d page_size=5
Paginated response
{
"count": 25,
"next": "https://<your-deployment-url>/api/cocktails/?page=3&page_size=5",
"previous": "https://<your-deployment-url>/api/cocktails/?page=1&page_size=5",
"results": [
{
"id": "1",
"name": "Margarita",
"ingredients": ["Tequila", "Lime juice", "Triple sec"]
},
{
"id": "2",
"name": "Mai Tai",
"ingredients": ["Rum", "Lime juice", "Orgeat syrup"]
}
// More cocktail objects...
]
}