Statistics¶
-
GET
/api/stats/
(user_name)/by_time
¶ Get workouts statistics for a user by time
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
HTTP/1.1 200 OK Content-Type: application/json { "data": { "statistics": { "2017": { "3": { "nb_workouts": 2, "total_ascent": 203.0, "total_ascent": 156.0, "total_distance": 15.282, "total_duration": 12341 } }, "2019": { "1": { "nb_workouts": 3, "total_ascent": 150.0, "total_ascent": 178.0, "total_distance": 47, "total_duration": 9960 }, "2": { "nb_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
auth_user_id (integer) – authenticate user id (from JSON Web Token)
user_name (integer) – user name
- 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)
- 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.
User does not exist.
-
GET
/api/stats/
(user_name)/by_sport
¶ Get workouts statistics for a user by sport
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
HTTP/1.1 200 OK Content-Type: application/json { "data": { "statistics": { "1": { "nb_workouts": 3, "total_ascent": 150.0, "total_ascent": 178.0, "total_distance": 47, "total_duration": 9960 }, "2": { "nb_workouts": 1, "total_ascent": 46.0, "total_ascent": 78.0, "total_distance": 5.613, "total_duration": 1267 }, "3": { "nb_workouts": 2, "total_ascent": 203.0, "total_ascent": 156.0, "total_distance": 15.282, "total_duration": 12341 } } }, "status": "success" }
no workouts
HTTP/1.1 200 OK Content-Type: application/json { "data": { "statistics": {} }, "status": "success" }
- Parameters
auth_user_id (integer) – authenticate user id (from JSON Web Token)
user_name (integer) – user name
- Query Parameters
sport_id (integer) – sport id
- 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.
User does not exist.
Sport does not exist.
-
GET
/api/stats/all
¶ Get all application statistics
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" }
- Parameters
auth_user_id (integer) – authenticate user id (from JSON Web Token)
- 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.