Supabase Stats Views
API Contract
REST
/api/v1/stats-views
8 endpoints
GET
/api/v1/stats-views/api/v1/stats-views/peer-mentor
Query the peer_mentor_stats_view for a user over a date range
Public
Response Example
{
"data": [
{
"user_id": "usr_4f8a2c",
"full_name": "Anna Johansson",
"total_activities": 47,
"completed_activities": 42,
"hours_logged": 128.5,
"start_date": "2026-01-01",
"end_date": "2026-03-26"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 1
}
}
GET
/api/v1/stats-views/api/v1/stats-views/peer-mentor/:userId
Get peer_mentor_stats_view row for a specific user
Public
Response Example
{
"user_id": "usr_4f8a2c",
"full_name": "Anna Johansson",
"total_activities": 47,
"completed_activities": 42,
"hours_logged": 128.5,
"start_date": "2026-01-01",
"end_date": "2026-03-26"
}
POST
/api/v1/stats-views/api/v1/stats-views/peer-mentor/query
Run a parameterized query against peer_mentor_stats_view
Public
Request Example
{
"user_id": "usr_4f8a2c",
"start_date": "2026-01-01",
"end_date": "2026-03-26"
}
Response Example
{
"user_id": "usr_4f8a2c",
"full_name": "Anna Johansson",
"total_activities": 47,
"completed_activities": 42,
"hours_logged": 128.5
}
GET
/api/v1/stats-views/api/v1/stats-views/coordinator-chapter
Query coordinator_chapter_stats_view for a list of chapters
Public
Response Example
{
"data": [
{
"chapter_id": "chp_oslo_01",
"chapter_name": "Oslo Sør",
"total_activities": 112,
"active_peer_mentors": 8,
"hours_logged": 320,
"start_date": "2026-01-01",
"end_date": "2026-03-26"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 1
}
}
POST
/api/v1/stats-views/api/v1/stats-views/coordinator-chapter/query
Run a parameterized query against coordinator_chapter_stats_view
Public
Request Example
{
"chapter_ids": [
"chp_oslo_01",
"chp_bergen_03"
],
"start_date": "2026-01-01",
"end_date": "2026-03-26"
}
Response Example
{
"data": [
{
"chapter_id": "chp_oslo_01",
"chapter_name": "Oslo Sør",
"total_activities": 112,
"active_peer_mentors": 8,
"hours_logged": 320
},
{
"chapter_id": "chp_bergen_03",
"chapter_name": "Bergen Nord",
"total_activities": 101,
"active_peer_mentors": 7,
"hours_logged": 294
}
]
}
GET
/api/v1/stats-views/api/v1/stats-views/activity-chart/daily
Query activity_chart_daily_view for daily data points
Public
Response Example
{
"data": [
{
"date": "2026-03-24",
"value": 1.5
},
{
"date": "2026-03-25",
"value": 2
},
{
"date": "2026-03-26",
"value": 0.5
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 3
}
}
GET
/api/v1/stats-views/api/v1/stats-views/activity-chart/weekly
Query activity_chart_weekly_view for weekly aggregated data points
Public
Response Example
{
"data": [
{
"week_start": "2026-03-01",
"value": 4
},
{
"week_start": "2026-03-08",
"value": 5.5
},
{
"week_start": "2026-03-15",
"value": 4
},
{
"week_start": "2026-03-22",
"value": 6.5
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 4
}
}
DELETE
/api/v1/stats-views/api/v1/stats-views/:viewName/cache
Invalidate the materialized view cache for a named view
Public
Response Example
{
"view_name": "activity_chart_daily_view",
"invalidated": true,
"invalidated_at": "2026-03-26T10:00:00Z"
}