---
title: Pagination and filters
description: Page through lists with page and size, and narrow them with single-word filters.
section: Core concepts
order: 5
---

# Pagination and 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

```json
{
	"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

```bash
curl "https://api.dev.nurishd.ca/meals/v1/vendor/query/documents?page=2&size=50" \
  -H "X-Partner-API-Key: $NURISHD_API_KEY"
```

```javascript
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;
	}
}
```

```python
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 += 1
```

## Filters

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](/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.

> **Note.** Lists have a default order, such as newest first for events. A change to the default order or page size is a breaking change, so you can rely on it within a version.

## Next

- [Events](/docs/events/events): list and filter events.
- [Catalog](/docs/meals/catalog): filters for products and menus.
- [Rate limits](/docs/concepts/rate-limits): fewer calls with a larger `size`.
