Appearance
Pagination
List endpoints return 25 items per page. The page size is fixed. Use page to move through results.
| Parameter | Type | Description |
|---|---|---|
page | integer | Page to return. Defaults to 1. |
bash
curl "https://api.canteenweb.com/api/v1/admin/orders?page=2" \
-H "Authorization: Bearer your-access-token" \
-H "X-CANTEEN-ORGANIZATION: your-org-uuid"Response
Paginated responses add links and meta next to data. The URLs in links keep the filters you sent, so following links.next is enough to walk a filtered list.
json
{
"data": [],
"links": {
"first": "https://api.canteenweb.com/api/v1/admin/orders?page=1",
"last": "https://api.canteenweb.com/api/v1/admin/orders?page=5",
"prev": "https://api.canteenweb.com/api/v1/admin/orders?page=1",
"next": "https://api.canteenweb.com/api/v1/admin/orders?page=3"
},
"meta": {
"current_page": 2,
"from": 26,
"last_page": 5,
"path": "https://api.canteenweb.com/api/v1/admin/orders",
"per_page": 25,
"to": 50,
"total": 120
},
"success": true,
"message": "Request was successful."
}| Field | Description |
|---|---|
meta.current_page | Page you are on. |
meta.last_page | Number of pages. |
meta.per_page | Items per page, always 25. |
meta.total | Total items matching the filters. |
meta.from, meta.to | Position of the first and last item of this page in the full list. |
links.prev, links.next | null on the first and last page respectively. |
meta also contains a links array meant for rendering page buttons. You can ignore it.
Walking every page
js
async function fetchAllOrders(params) {
const headers = {
'Authorization': 'Bearer your-access-token',
'X-CANTEEN-ORGANIZATION': 'your-org-uuid',
'Accept': 'application/json',
}
let url = 'https://api.canteenweb.com/api/v1/admin/orders?' + new URLSearchParams(params)
const orders = []
while (url) {
const body = await (await fetch(url, { headers })).json()
orders.push(...body.data)
url = body.links.next
}
return orders
}Fetch pages one after another. The rate limit is per minute, and a list of a few hundred orders is a handful of requests.

