> ## Documentation Index
> Fetch the complete documentation index at: https://docs.creatoraudit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Filtering and sorting

> Narrow collections with filter params and order results with order_by/order_direction.

List endpoints accept query parameters that filter and sort the rows they return.
The available filters and the set of sortable fields vary per endpoint, so always
confirm the exact parameters on the relevant endpoint page.

## Filtering

Common filter parameters across list endpoints:

<ParamField query="platform" type="string">
  Restrict to one platform — `instagram` or `tiktok`.
</ParamField>

<ParamField query="q" type="string">
  Case-insensitive substring search (for example, over an account's username).
</ParamField>

<ParamField query="is_active" type="boolean">
  Filter by tracking state — active versus paused.
</ParamField>

<ParamField query="account_id" type="string">
  Scope results to a single account (UUID). Available where it makes sense, such as
  listing videos.
</ParamField>

<ParamField query="creator_id" type="string">
  Scope accounts to a single creator (UUID).
</ParamField>

Filters combine with `AND`. The response echoes the active filter and sort back in
the `filters` envelope so you can confirm what produced the page.

```bash theme={null}
# Active Instagram accounts whose username matches "studio"
curl "https://api.creatoraudit.com/v2/accounts?platform=instagram&is_active=true&q=studio" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

<Note>
  Filter parameters are per-endpoint. For example, `/v2/accounts` also accepts
  `category` and `creator_id`, while `/v2/videos` accepts `account_id`. Check the
  endpoint page for the full list.
</Note>

### Date ranges

The analytics endpoints accept date-range parameters instead of the filters above.
Daily endpoints take an inclusive `start_date` and `end_date` (`YYYY-MM-DD`), and
the timeseries endpoints add a `period` preset (`7d`, `30d`, `90d`, or `custom`
with explicit dates). See the analytics endpoints in the
[API reference](/api-reference/introduction) for specifics.

## Sorting

Sort with two parameters:

<ParamField query="order_by" type="string">
  Field to sort by. Allowed values are a per-endpoint enum (see below).
</ParamField>

<ParamField query="order_direction" type="string" default="desc">
  Sort direction — `asc` or `desc`.
</ParamField>

```bash theme={null}
# Accounts with the most followers first
curl "https://api.creatoraudit.com/v2/accounts?order_by=follower_count&order_direction=desc" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Sortable fields are specific to each endpoint. For example:

| Endpoint       | `order_by` values                                                                                      |
| -------------- | ------------------------------------------------------------------------------------------------------ |
| `/v2/accounts` | `added_at`, `username`, `last_scrape_time`, `follower_count`, `view_count`, `like_count`, `play_count` |
| `/v2/videos`   | `added_at`, `create_time`, `view_count`, `like_count`, `play_count`                                    |

The endpoint page is the source of truth for each list's allowed values — see the
[API reference](/api-reference/introduction).

<Note>
  A legacy `sort` parameter accepts a single signed string such as `-added_at` (leading
  `-` for descending). Prefer `order_by` + `order_direction`, which are validated as
  enums; if both are present, `order_by` wins.
</Note>

## Combining with pagination

Filters and sort are part of the cursor's identity. Hold them constant across every
page of a walk — a cursor reused under a different filter or sort returns `422`.
See [Pagination](/api-reference/pagination).
