# Filtering and sorting

Filters are passed as query string parameters. Several filters at once are combined (AND).

## Channel catalog — `GET /v1/max/channels/`

| Parameter | What it does |
|---|---|
| `q` | Search: a substring of the title or handle (from 3 characters), a `max.ru/…` link or a `@handle` — exact match |
| `category` | Category code (primary or additional) from the category directory |
| `territory` | Territory code from the directory — including child nodes (Moscow is found by the Central Federal District code too) |
| `kind` | `channel` — channels (default), `chat` — group chats |
| `subscribers_min`, `subscribers_max` | At least / at most this many subscribers |
| `a_plus` | `true` — only with the A+ mark, `false` — without it |
| `verified` | `true` — only owner-verified, `false` — unverified |
| `ids` | Up to 100 comma-separated numbers — cards in request order; other filters and pagination don’t apply then |

## Catalog sorting — `ordering`

Always descending:

| Value | Order |
|---|---|
| `-subscribers` | More subscribers first (default) |
| `-quality` | Higher quality index |
| `-citation` | Higher citation index |
| `-last_post_at` | More recent last post |

Channels without a value (for example, without a quality index) come last.

## Channel posts — `GET /v1/max/channels/{channel}/posts/`

| Parameter | What it does |
|---|---|
| `from`, `to` | Publication period: days as `YYYY-MM-DD` in Moscow time, both inclusive |
| `is_ad` | `true` — advertising posts only, `false` — without advertising |

## Daily statistics — `GET /v1/max/stats/daily/`

| Parameter | What it does |
|---|---|
| `channels` | Required: up to 100 comma-separated channel numbers |
| `from`, `to` | Inclusive period, the last 30 days by default; no longer than 366 days, channels × days — no more than 10,000 |

## Territory directory — `GET /v1/max/territories/`

| Parameter | What it does |
|---|---|
| `parent` | A node code — only its direct children |
| `kind` | Only nodes of a level: `country`, `district`, `region`, `city` |

## Parameter values

- Yes / no: `true` or `false` (also `1` / `0`, `yes` / `no`).
- An invalid value or an unknown category or territory code — response 400 with the error under the parameter name.
