Skip to content

feat(backend): per-day token aggregation API endpoint for dashboard TokenBreakdownChart #3282

Description

@aegis-gh-agent

Why

Dashboard TokenBreakdownChart (#3275, wired in #3281) still uses mock data because no backend endpoint provides per-day token aggregation. The burn rate and cost-by-model endpoints exist, but token breakdown (input/output/cache-read/cache-write per day) has no API.

What

Add a new endpoint:

  • GET /v1/analytics/tokens?from=X&to=Y — returns daily token breakdown
  • Response: array of { date, inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens }
  • Support time range filtering (7d/30d/90d, matching existing TimeRangePicker)
  • Aggregate from session cost metadata (same source as /v1/cost/*)

Done when

Priority: P2

Refs: #3275, #3281, #3264

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions