Pagination and filters
Page through lists with page and size, and narrow them with single-word filters.
You will page through any list and narrow it with filters.
Parameters#
Every list route takes page and size.
| Parameter | Default | Rule |
|---|---|---|
page | 1 | From 1. |
size | 10 | From 1 to 50. |
The answer#
{
"data": [
{ "vendor_id": "vendor-0001", "vendor_name": "Green Table Kitchen" }
],
"total_pages": 3,
"total": 25,
"page": 1,
"size": 10,
"has_next": true,
"has_previous": false
}data holds the items (trimmed here). The other fields describe the page. Stop when has_next is false.
Walk every page#
curl "https://api.dev.nurishd.ca/meals/v1/vendor/query/documents?page=2&size=50" \
-H "X-Partner-API-Key: $NURISHD_API_KEY"async function allVendors() {
const vendors = [];
for (let page = 1; ; page++) {
const res = await fetch(
`https://api.dev.nurishd.ca/meals/v1/vendor/query/documents?page=${page}&size=50`,
{ headers: { 'X-Partner-API-Key': process.env.NURISHD_API_KEY } },
);
const body = await res.json();
vendors.push(...body.data);
if (!body.has_next) return vendors;
}
}import os
import requests
def all_vendors():
vendors, page = [], 1
while True:
res = requests.get(
"https://api.dev.nurishd.ca/meals/v1/vendor/query/documents",
params={"page": page, "size": 50},
headers={"X-Partner-API-Key": os.environ["NURISHD_API_KEY"]},
)
body = res.json()
vendors.extend(body["data"])
if not body["has_next"]:
return vendors
page += 1Filters#
Filters are single words in the query string, such as name, type, status, from and to. Each route lists its own. Filter values are the internal values of the resource, for example type=Meal or status=meeting_cancelled. Check the spelling and the values against the API reference.
| Route | Filters |
|---|---|
GET /meals/v1/vendor/query/documents | name |
GET /meals/v1/vendor/{vendor_id}/menu/query/documents | status |
GET /meals/v1/vendor/{vendor_id}/product/query/documents | name, type, collection, tag |
GET /meals/v1/zone/query/documents | city, state, country (required), vendor |
GET /developer/v1/event/query/documents | type, from, to |
A filter with a bad value answers 422 validation_error. Combine filters freely.
Next#
- Events: list and filter events.
- Catalog: filters for products and menus.
- Rate limits: fewer calls with a larger
size.
Something wrong on this page? Email hello@nurishd.io with the page address.