> For the complete documentation index, see [llms.txt](https://docs.millimetric.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.millimetric.ai/api-reference/query.md).

# GET /v1/query

Return raw event rows matching a time range and optional filters. For debugging, ad-hoc inspection, and small reports.

## Auth

|                |        |
| -------------- | ------ |
| Required scope | `read` |
| Key kinds      | `rk_*` |

## Request

```http
GET /v1/query?from=2026-05-01T00:00:00Z&to=2026-05-16T00:00:00Z&event=signup&limit=100
Authorization: Bearer rk_live_…
```

### Query parameters

| Name      | Required | Notes                                                   |
| --------- | -------- | ------------------------------------------------------- |
| `from`    | **yes**  | ISO 8601 timestamp (inclusive).                         |
| `to`      | **yes**  | ISO 8601 timestamp (exclusive).                         |
| `event`   | no       | Filter to one event name (`signup`, `$pageview`, etc.). |
| `source`  | no       | Filter to one source (`facebook`, `google`, etc.).      |
| `medium`  | no       | Filter to one medium (`paid`, `social`, etc.).          |
| `user_id` | no       | Filter to events tagged with this `user_id`.            |
| `limit`   | no       | 1–1000, default 100.                                    |

## Response

```json
{
  "rows": [
    {
      "timestamp": "2026-05-16T19:31:23.217Z",
      "event_name": "signup",
      "anonymous_id": "u_fbpaid_1",
      "user_id": "user_001",
      "source": "facebook",
      "medium": "paid",
      "campaign": "spring",
      "source_confidence": "high",
      "referrer": "https://l.facebook.com/",
      "url": "https://yoursite.com/?utm_source=facebook&utm_medium=cpc&fbclid=abc",
      "path": "/",
      "country": "GB",
      "device_type": "desktop",
      "properties": "{\"plan\":\"free\"}"
    }
  ]
}
```

`properties` is returned as a JSON string (because ClickHouse stores it as `String`). Parse client-side.

## When NOT to use this

For aggregations (`count`, `uniq`, `group by`), use [`/v1/stats`](/api-reference/stats.md) — it's an order of magnitude cheaper than fetching raw rows and aggregating in your code.

For top-source breakdowns specifically, use [`/v1/sources`](/api-reference/sources.md).

## Example: last 20 events from a specific user

```bash
curl -G "https://api.millimetric.ai/v1/query" \
  -H "Authorization: Bearer $RK_KEY" \
  --data-urlencode "from=2026-05-01T00:00:00Z" \
  --data-urlencode "to=2026-05-17T00:00:00Z" \
  --data-urlencode "user_id=user_42" \
  --data-urlencode "limit=20"
```

## Example: paid Facebook traffic this week

```bash
curl -G "https://api.millimetric.ai/v1/query" \
  -H "Authorization: Bearer $RK_KEY" \
  --data-urlencode "from=2026-05-10T00:00:00Z" \
  --data-urlencode "to=2026-05-17T00:00:00Z" \
  --data-urlencode "source=facebook" \
  --data-urlencode "medium=paid"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.millimetric.ai/api-reference/query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
