> For a complete page index of the Captain API documentation, fetch https://docs.captain.dev/llms.txt?excludeSpec=true

# Get Analytics

GET https://acme.captain.dev/v1/indexes/{index}/analytics

Get the main search metrics for a period in one call. On an index with per-record access control, analytics is available through Captain.

Reference: https://docs.captain.dev/reference/product-search/analytics/get-analytics

## Authentication

- `Authorization` header (bearer token, required) — A search key, issued by Captain. Sent as Authorization: Bearer \<key>.

## Request

### Path parameters

- `index` (string, required) — index name

### Query parameters

- `days` (double, optional, default: 7) — the last days * 24 hours, when no start_date or end_date is sent
- `start_date` (string, optional) — first day, UTC, inclusive (YYYY-MM-DD). Default: 6 days before end_date (a 7-day window). Sending either one replaces days
- `end_date` (string, optional) — last day, UTC, inclusive (YYYY-MM-DD). Default: today. At most 366 days from start_date. Sending either one replaces days
- `start_time` (string, optional) — an exact start instead of start_date: unix seconds, or ISO 8601 in UTC (2026-10-10T10:00:00Z). start_date and end_date in the reply are then the UTC days the window touches. Sending either one replaces days
- `end_time` (string, optional) — an exact end (exclusive): unix seconds or ISO 8601 with Z. Default: now; never later than now. Must be after start_time. Sending either one replaces days

## Response

### 200

report

- `dataset` (string, optional) — the index
- `days` (double, optional)
- `start_date` (string, optional)
- `end_date` (string, optional)
- `search_requests` (integer, optional) — every search and typeahead request
- `searches` (integer, optional) — searches, with the keystrokes that led to each counted once
- `top_queries` (list of AnalyticsReportTopQueriesItems, optional)
- `zero_result_queries` (list of AnalyticsReportZeroResultQueriesItems, optional)
- `zero_result_rate` (double, optional)
- `events` (map from string to integer, optional) — event counts by type
- `click_through_rate` (double, optional, nullable)
- `mean_click_position` (double, optional, nullable)
- `conversion_rate` (double, optional, nullable)
- `tracked_searches` (integer, optional) — searches that carried a user token
- `partial` (boolean, optional) — true when the search log was too large to read whole within one request's budget: the numbers cover what was counted
- `partial_reason` (enum, optional) — row_budget: more searches than one request holds (500,000); time_budget: more than about 3.5 seconds of reading; counting (usage): days still being counted
  - Allowed values: `row_budget`, `time_budget`, `counting`
- `counted_through` (double, optional, nullable) — the time (unix seconds) of the last record counted, when partial

## Types

### AnalyticsReportTopQueriesItems

- `query` (string, optional)
- `count` (integer, optional)
- `avg_hits` (double, optional)

### AnalyticsReportZeroResultQueriesItems

- `query` (string, optional)
- `count` (integer, optional)

## Examples

**Response**

```json
{
  "dataset": "products",
  "days": 7,
  "search_requests": 48213,
  "searches": 9604,
  "top_queries": [
    {
      "query": "hiking boots",
      "count": 412,
      "avg_hits": 42
    },
    {
      "query": "rain jacket",
      "count": 355,
      "avg_hits": 18
    },
    {
      "query": "trail running shoes",
      "count": 298,
      "avg_hits": 37
    }
  ],
  "zero_result_queries": [
    {
      "query": "gaiter size chart",
      "count": 21
    },
    {
      "query": "crampons",
      "count": 14
    }
  ],
  "zero_result_rate": 0.0187,
  "events": {
    "click": 3920,
    "conversion": 611,
    "view": 12078
  },
  "click_through_rate": 0.3842,
  "mean_click_position": 2.34,
  "conversion_rate": 0.0642,
  "tracked_searches": 9517
}
```

**SDK Code**

```python Python REST
import json
import requests

BASE_URL = "https://acme.captain.dev"
API_KEY = "your_search_key"
INDEX = "products"

headers = {
    "Authorization": f"Bearer {API_KEY}",
}

response = requests.get(
    f"{BASE_URL}/v1/indexes/{INDEX}/analytics",
    headers=headers,
    params={"days": 7},
    timeout=30.0,
)

print(json.dumps(response.json(), indent=2))
```

```typescript TypeScript REST
const BASE_URL = "https://acme.captain.dev";
const API_KEY = "your_search_key";
const index = "products";

const params = new URLSearchParams({ days: "7" });

const response = await fetch(`${BASE_URL}/v1/indexes/${index}/analytics?${params}`, {
  method: "GET",
  headers: {
    Authorization: `Bearer ${API_KEY}`,
  },
});

const result = await response.json();
console.log(JSON.stringify(result, null, 2));
```