# Analytics API Reference

Analytics data is read via the dashboard-worker which queries Supabase views directly.


# Get Video Statistics

GET /dashboard/videos/:id/stats

Returns the statistics history for a single video.

Response

{
  "success": true,
  "data": {
    "video_id": "...",
    "stats": [
      {
        "created_at": "2026-03-01T00:00:00Z",
        "views": 15000,
        "likes": 320,
        "comments": 45,
        "reposts": 12
      }
    ],
    "daily_increments": [
      {
        "date": "2026-03-01",
        "views_delta": 500,
        "likes_delta": 10
      }
    ]
  }
}

# Get Organization Stats

GET /dashboard/stats

Returns aggregated stats for all tracked videos in the organization.

Query params: from, to, campaign, platform


# Get Videos With Increments for Date

GET /analytics/videos/for_date

Returns videos with their daily metric increments for a specific date, sorted by the requested metric. Used to populate the "top videos" detail view when clicking a date on a chart.

Distinct from videos_published/for_date — that endpoint returns total stats for videos published on a date; this returns increment stats for all tracked videos on that date.

Query params

Param Required Description
date Yes Date in YYYY-MM-DD format
limit No Max results (default 10000)
sort_by No Metric to sort by: views, likes, saves, comments, reposts (default views)
platform No Comma-separated platform filter
campaign_tag No Comma-separated campaign filter
channel_username No Comma-separated blogger filter
tag_ids No Comma-separated tag ID filter
published_from No Filter by video publish date range start
published_to No Filter by video publish date range end

Response

{
  "success": true,
  "data": [
    {
      "video_id": "uuid",
      "external_video_id": "abc123",
      "thumbnail_url": "https://...",
      "video_url": "https://...",
      "blogger_channel_username": "example",
      "platform": "youtube",
      "campaign_tag": "spring2026",
      "views_increment": 12500,
      "likes_increment": 340,
      "comments_increment": 45,
      "reposts_increment": 12,
      "saves_increment": 89,
      "published_at": "2026-02-01T00:00:00Z",
      "created_at": "2026-01-15T00:00:00Z"
    }
  ]
}

Data source: Supabase RPC get_top_videos_increments_on_date


# Data Sources

Endpoint DB Source
Single video stats video_statistics
Daily increments mv_video_daily_increments
Weekly summary mv_video_weekly_increments
Video list with totals videos_with_statistics_fast