# Analytics

Usage rollups: global and daily totals, per-session detail, the session list that backs the project breakdown, the leaderboard, and the combined data payload.

Playground

Send these requests to your own running server. Values stay in this browser.

Not connected

Base URL  Directory _optional_  Bearer token _optional_ 

 

How this works

Start a server with `nikcli serve --hostname 127.0.0.1 --port 4096`. Requests go straight from this page to that address — the browser allows it because loopback counts as a secure origin, and the server allows it because `nikcli-ai.dev` is in its CORS allowlist.

To try things without touching your real sessions or config, start the server with `NIKCLI_TEST_HOME` pointed at a throwaway directory — see [the guided tour](/docs/guides/api-tour).

## Operations

6 endpoints, generated from the server's own [OpenAPI document](/docs/api). Every path also accepts the `directory` and `workspace` query parameters that select which instance handles the request.

<table class="api-index not-prose"><tbody><tr><td class="api-index-method"><span class="api-method api-method-get">get</span></td><td><a href="#op-get-analytics-global">/analytics/global</a></td><td class="api-index-id">analytics.global</td></tr><tr><td class="api-index-method"><span class="api-method api-method-get">get</span></td><td><a href="#op-get-analytics-daily">/analytics/daily</a></td><td class="api-index-id">analytics.daily</td></tr><tr><td class="api-index-method"><span class="api-method api-method-get">get</span></td><td><a href="#op-get-analytics-session-sessionID">/analytics/session/{sessionID}</a></td><td class="api-index-id">analytics.session</td></tr><tr><td class="api-index-method"><span class="api-method api-method-get">get</span></td><td><a href="#op-get-analytics-sessions">/analytics/sessions</a></td><td class="api-index-id">analytics.sessions</td></tr><tr><td class="api-index-method"><span class="api-method api-method-get">get</span></td><td><a href="#op-get-analytics-leaderboard">/analytics/leaderboard</a></td><td class="api-index-id">analytics.leaderboard</td></tr><tr><td class="api-index-method"><span class="api-method api-method-get">get</span></td><td><a href="#op-get-analytics-data">/analytics/data</a></td><td class="api-index-id">analytics.data</td></tr></tbody></table>

get /analytics/global [#](#op-get-analytics-global) `analytics.global`

Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| directory | query | string | optional |
| workspace | query | string | optional |

Responses

200 AnalyticsGlobal application/json

{
  version: 1
  updatedAt: 
    | number
    | "Infinity" | "-Infinity" | "NaN"
  totals: {
    sessions: 
      | number
      | "Infinity" | "-Infinity" | "NaN"
    messages: 
      | number
      | "Infinity" | "-Infinity" | "NaN"
    tokens: [AnalyticsTokenBreakdown](#schema-AnalyticsTokenBreakdown)
    cost: 
      | number
      | "Infinity" | "-Infinity" | "NaN"
    toolCalls: 
      | number
      | "Infinity" | "-Infinity" | "NaN"
  }
  byProvider: {
    \[key: string\]: [AnalyticsProviderStat](#schema-AnalyticsProviderStat)
  }
  byModel: {
    \[key: string\]: [AnalyticsModelStat](#schema-AnalyticsModelStat)
  }
  byProject: {
    \[key: string\]: [AnalyticsProjectStat](#schema-AnalyticsProjectStat)
  }
}

Example response from schema

{
  "version": 1,
  "updatedAt": 0,
  "totals": {
    "sessions": 0,
    "messages": 0,
    "tokens": {
      "input": 0,
      "output": 0,
      "reasoning": 0,
      "cacheRead": 0,
      "cacheWrite": 0
    },
    "cost": 0,
    "toolCalls": 0
  },
  "byProvider": {},
  "byModel": {},
  "byProject": {}
}

Generated from the response schema — field values are placeholders, the shape is real.

SDK example

analytics.global

ts 

1

2

3

4

5

6

```
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"

const client = createNikcliClient()
await client.analytics.global({
  ...
})
```

Try it

directory _query_  workspace _query_

---

Source: https://nikcli-ai.dev/docs/api/analytics
