# Query data

Query your app's data with `getstream api`. Responses are JSON and can be processed using jq syntax, in the terminal, a script, or by your agent.

For example, the channels user `alice` belongs to, most recently active first:

```sh
getstream api QueryChannels --request '{
  "filter_conditions": {
    "members": { "$in": ["alice"] }
  },
  "sort": [{ "field": "last_message_at", "direction": -1 }],
  "limit": 10
}'
```

Like every app-scoped command, `api` acts on the current project's app unless `--app-id` or the `STREAM_API_KEY` and `STREAM_API_SECRET` environment variables override it.

Most query endpoints support filtering with `filter_conditions` (see [Query syntax](https://getstream.io/docs/platform/query-syntax-operators/)) and sorting with `sort`. Pagination is handled by `offset` or `next` cursors. Refer to the help page for each endpoint:

```sh
getstream api QueryChannels --help
```

Add `--jq` to process a response with a [jq](https://jqlang.org/) expression before it is printed:

```sh
getstream api QueryUsers --request '{
  "filter_conditions": { "role": "admin" },
  "limit": 100
}' --jq '.users[] | {id, name}'
```

In non-interactive terminals, long arrays are truncated in responses to keep logs readable and avoid excessive context usage in agents. A `--jq` result is never shortened and it should be preferred in automated usage.

When working with an agent, just ask:

- Which channels had no messages in the last 30 days?
- How many users signed up this week?
- List the calls that are live right now.
- Show me the flagged messages nobody has reviewed yet.

---

For the most recent version of this documentation, visit [https://getstream.io/cli/docs/query-data/](https://getstream.io/cli/docs/query-data/).