Statistics¶
- GET /api/stats/(user_name)/by_time¶
Get workouts statistics for a user by time. For now only authenticated users can access their statistics.
Scope:
workouts:read
Example requests:
without parameters:
GET /api/stats/admin/by_time HTTP/1.1
with parameters:
GET /api/stats/admin/by_time?from=2018-01-01&to=2018-06-30&time=week HTTP/1.1
Example responses:
success for total:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "statistics": { "2017": { "3": { "total_workouts": 2, "total_ascent": 203.0, "total_ascent": 156.0, "total_distance": 15.282, "total_duration": 12341 } }, "2019": { "1": { "total_workouts": 3, "total_ascent": 150.0, "total_ascent": 178.0, "total_distance": 47, "total_duration": 9960 }, "2": { "total_workouts": 1, "total_ascent": 46.0, "total_ascent": 78.0, "total_distance": 5.613, "total_duration": 1267 } } } }, "status": "success" }
success for average:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "statistics": { "2017": { "3": { "average_ascent": 101.5, "average_ascent": 78.0, "average_distance": 15.282, "average_duration": 7641, "average_speed": 4.48, "total_workouts": 2 } }, "2019": { "1": { "average_ascent": 50.0, "average_descent": 59.33, "average_distance": 15.67, "average_duration": 3320, "average_speed": 16.99, "total_workouts": 3 }, "2": { "average_ascent": 46.0, "average_descent": 78.0, "average_distance": 5.613, "average_duration": 1267, "average_speed": 15.95, "total_workouts": 1 } } } }, "status": "success" }
no workouts:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "statistics": {} }, "status": "success" }
- Parameters:
user_name (integer) – username
- Query Parameters:
from (string) – start date (format:
%Y-%m-%d
)to (string) – end date (format:
%Y-%m-%d
)time (string) –
time frame:
week
: week starting Sundayweekm
: week starting Mondaymonth
: monthyear
: year (default)
type (string) –
stats type:
total
: calculating totalsaverage
: calculating averages
- Request Headers:
Authorization – OAuth 2.0 Bearer Token
- Status Codes:
200 OK –
success
invalid stats type
invalid time period
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
404 Not Found –
user does not exist
- GET /api/stats/(user_name)/by_sport¶
Get workouts statistics for a user by sport. For now only authenticated users can access their statistics.
Scope:
workouts:read
Example requests:
without parameters (get stats for all sports with workouts):
GET /api/stats/admin/by_sport HTTP/1.1
with sport id:
GET /api/stats/admin/by_sport?sport_id=1 HTTP/1.1
Example responses:
success for all sports:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "statistics": { "1": { "average_ascent": 50.0, "average_descent": 59.33, "average_distance": 15.67, "average_duration": 3320, "average_speed": 16.99, "total_workouts": 3, "total_ascent": 150.0, "total_ascent": 178.0, "total_distance": 47, "total_duration": 9960 }, "2": { "average_ascent": 46.0, "average_descent": 78.0, "average_distance": 5.613, "average_duration": 1267, "average_speed": 15.95, "total_workouts": 1, "total_ascent": 46.0, "total_ascent": 78.0, "total_distance": 5.613, "total_duration": 1267 }, "3": { "average_ascent": 101.5, "average_ascent": 78.0, "average_distance": 15.282, "average_duration": 7641, "average_speed": 4.48, "total_workouts": 2, "total_ascent": 203.0, "total_ascent": 156.0, "total_distance": 15.282, "total_duration": 12341 } } }, "status": "success" }
success for a given sport:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "statistics": { "2": { "average_ascent": 46.0, "average_descent": 78.0, "average_distance": 5.613, "average_duration": 1267, "average_speed": 15.95, "total_workouts": 1, "total_ascent": 46.0, "total_ascent": 78.0, "total_distance": 5.613, "total_duration": 1267 } } }, "status": "success" }
no workouts:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "statistics": {} }, "status": "success" }
- Parameters:
user_name (integer) – username
- Query Parameters:
sport_id (integer) – sport id (not mandatory). If not provided, statistics for all sports are returned.
- Request Headers:
Authorization – OAuth 2.0 Bearer Token
- Status Codes:
200 OK –
success
invalid stats type
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
user does not exist
sport does not exist
- GET /api/stats/all¶
Get all application statistics.
Scope:
workouts:read
Example requests:
GET /api/stats/all HTTP/1.1
Example responses:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "sports": 3, "uploads_dir_size": 1000, "users": 2, "workouts": 3, }, "status": "success" }
- Request Headers:
Authorization – OAuth 2.0 Bearer Token
- Status Codes:
200 OK –
success
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
403 Forbidden –
you do not have permissions