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

# Analytics

> API endpoints for fetching security metrics and time-series data

## Get Summary

Returns aggregated security metrics for the organization (or a single device) over a given time window.

```
GET /api/analytics/summary
```

### Query Parameters

| Parameter   | Type   | Required | Description                |
| ----------- | ------ | -------- | -------------------------- |
| `window`    | string | Yes      | `24h` or `30d`             |
| `device_id` | string | No       | Scope to a specific device |

### Response

```json theme={null}
{
  "total_analyzed": 48210,
  "dangerous_blocks": 34,
  "risky_warnings": 182,
  "avg_classification_ms": 12.4
}
```

| Field                   | Type   | Description                         |
| ----------------------- | ------ | ----------------------------------- |
| `total_analyzed`        | number | Total URLs classified               |
| `dangerous_blocks`      | number | URLs blocked as malicious           |
| `risky_warnings`        | number | URLs flagged as potentially harmful |
| `avg_classification_ms` | number | Mean classification latency (ms)    |

***

## Get Time Series

Returns time-bucketed data for charting. Buckets are **hourly** for `24h` and **daily** for `30d`.

```
GET /api/analytics/series
```

### Query Parameters

| Parameter   | Type   | Required | Description                                                                            |
| ----------- | ------ | -------- | -------------------------------------------------------------------------------------- |
| `metric`    | string | Yes      | One of `total_analyzed`, `dangerous_blocks`, `risky_warnings`, `avg_classification_ms` |
| `window`    | string | Yes      | `24h` or `30d`                                                                         |
| `device_id` | string | No       | Scope to a specific device                                                             |

### Response

```json theme={null}
{
  "metric": "dangerous_blocks",
  "window": "24h",
  "data": [
    { "timestamp": "2025-10-14T00:00:00Z", "value": 2 },
    { "timestamp": "2025-10-14T01:00:00Z", "value": 0 },
    { "timestamp": "2025-10-14T02:00:00Z", "value": 5 }
  ]
}
```

***

## Health Check

Returns `200 OK` if the API is reachable. No authentication required.

```
GET /api/analytics/health
```

### Response

```json theme={null}
{ "status": "ok" }
```
