Skip to content

API Stats

Wallace Ricardo edited this page Jun 3, 2026 · 2 revisions

Stats API

Aggregate statistics across all recorded data.

Query

{
  stats {
    totalSessions
    totalHooks
    totalErrors
    avgHooksPerSession
    hooksByEventType { eventType count }
    topTools(limit: 10) { name count }
    hooksByDay(days: 30) { date count }
    hooksByCwd(limit: 10) { cwd hookCount sessionCount }
    toolErrorRates {
      toolName
      totalCalls
      errorCount
      errorRate
    }
    totalTokenUsage {
      inputTokens
      outputTokens
      cacheReadTokens
      cacheCreationTokens
    }
  }
}

Fields

Field Description
totalSessions Total sessions in the database
totalHooks Total hook events recorded
totalErrors Total detected tool errors
avgHooksPerSession Average hooks per session
hooksByEventType Hook count per event type
topTools(limit) Most-used tools by call count
hooksByDay(days) Hook counts grouped by calendar day for the last N days (sparse — days with zero hooks are omitted)
hooksByCwd(limit) Most active working directories by hook count
toolErrorRates Per-tool error rate: total calls, error count, and ratio
totalTokenUsage Aggregate token usage from available transcript files

Example: activity heatmap data

{ stats { hooksByDay(days: 7) { date count } } }

Example: top tools and token totals

{
  stats {
    topTools(limit: 10) { name count }
    totalTokenUsage { inputTokens outputTokens cacheReadTokens cacheCreationTokens }
  }
}

Example: which tools fail most often

{
  stats {
    toolErrorRates {
      toolName
      totalCalls
      errorCount
      errorRate
    }
  }
}

Clone this wiki locally