Skip to main content

Analytics API

The Analytics API provides admin-only summaries used by the GOFA B2B insights dashboard.

Overview Metrics

GET /api/client/[clientId]/analytics/overview

Returns the summary cards for the B2B dashboard, including participant totals, high-risk counts, average age, risk distribution, and assessment completion rate.

For B2B tenants, the participant total is based on the same participant population shown on the Players page so the dashboard and participant list stay aligned.

Response
{
"totalLinkedPlayers": 43,
"highRiskCount": 8,
"averageAge": 71,
"urgentAttentionCount": 2,
"riskDistribution": {
"level1": 8,
"level2": 21,
"level3": 6,
"level4": 2
},
"ageDistribution": {
"30-39": 0,
"40-49": 1,
"50-59": 3,
"60-69": 12,
"70-79": 17,
"80-89": 8,
"90+": 2
},
"assessmentCompletionRate": 65
}

Authentication

Use an admin-capable Firebase token in the Authorization: Bearer <firebase_jwt> header.

note

These endpoints are intended for B2B administrators who need tenant-level insight summaries. Standard end-user tokens without admin access are rejected.

Engagement Insights

GET /api/client/[clientId]/analytics/engagement-insights

Returns aggregated engagement metrics for the selected client across the main activity modules shown in the B2B dashboard.

For non-gofa tenants, results are scoped to members linked to that client. For the gofa tenant, the response reflects the broader admin view.

Query Parameters:

ParameterTypeRequiredDescription
startDatestringNoInclusive start date in YYYY-MM-DD format
endDatestringNoInclusive end date in YYYY-MM-DD format

When startDate and endDate are provided, the endpoint returns recent activity for that range instead of lifetime totals.

Response
{
"success": true,
"lessons": {
"activeUsers": 48,
"totalPlays": 182,
"completedPlays": 121
},
"aiMove": {
"activeUsers": 33,
"totalSessions": 96,
"completedSessions": 74,
"totalReps": 2840
},
"aiNutrition": {
"activeUsers": 27,
"totalFoodLogs": 154,
"totalPlans": 36,
"totalChatSessions": 19
},
"waterIntake": {
"activeUsers": 22,
"totalLogs": 308,
"totalAmountMl": 78600
},
"wellnessChat": {
"activeUsers": 18,
"totalChats": 41,
"totalMessages": 266
},
"metadata": {
"generatedAt": "2026-03-24T09:15:00.000Z",
"queryClientId": "gofa",
"isGofaAdmin": true,
"linkedPlayers": 152,
"startDate": "2026-02-24",
"endDate": "2026-03-24"
}
}

Notes

  • This endpoint returns aggregated counts only.
  • The response is designed for dashboard visualisation and operational reporting.
  • The module mix may evolve as new B2B insights are added.

Assessment Counts

GET /api/client/[clientId]/analytics/assessment-counts

Returns fall-risk, cognitive, and MSK assessment totals broken down by completion state, origin, and client.

Query Parameters:

ParameterTypeRequiredDescription
startDatestringNoInclusive start date in YYYY-MM-DD format
endDatestringNoInclusive end date in YYYY-MM-DD format

When a range is supplied, only assessments with timestamps inside that window are included.

Functional Tests

GET /api/client/[clientId]/analytics/functional-tests

Returns the age-grouped functional test summary used in Health Insights.

Query Parameters:

ParameterTypeRequiredDescription
startDatestringNoInclusive start date in YYYY-MM-DD format
endDatestringNoInclusive end date in YYYY-MM-DD format

When a range is supplied, only fall-risk assessment results with timestamps inside that window are considered for the averages.