Sports¶
- GET /api/sports¶
Get all sports.
Suspended user can access this endpoint.
Scope:
workouts:read
Example request:
GET /api/sports HTTP/1.1 Content-Type: application/json
Example response:
for non admin user:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "sports": [ { "color": null, "id": 1, "is_active": true, "is_active_for_user": true, "label": "Cycling (Sport)", "stopped_speed_threshold": 1 }, { "color": null, "id": 2, "is_active": true, "is_active_for_user": true, "label": "Cycling (Transport)", "stopped_speed_threshold": 1 }, { "color": null, "id": 3, "is_active": true, "is_active_for_user": true, "label": "Hiking", "stopped_speed_threshold": 0.1 }, { "color": null, "id": 4, "is_active": true, "is_active_for_user": true, "label": "Mountain Biking", "stopped_speed_threshold": 1 }, { "color": null, "id": 5, "is_active": true, "is_active_for_user": true, "label": "Running", "stopped_speed_threshold": 0.1 }, { "color": null, "id": 6, "is_active": true, "is_active_for_user": true, "label": "Walking", "stopped_speed_threshold": 0.1 } ] }, "status": "success" }
for admin user and check_workouts=true:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "sports": [ { "color": null, "has_workouts": true, "id": 1, "is_active": true, "is_active_for_user": true, "label": "Cycling (Sport)", "stopped_speed_threshold": 1 }, { "color": null, "has_workouts": false, "id": 2, "is_active": true, "is_active_for_user": true, "label": "Cycling (Transport)", "stopped_speed_threshold": 1 }, { "color": null, "has_workouts": false, "id": 3, "is_active": true, "is_active_for_user": true, "label": "Hiking", "stopped_speed_threshold": 0.1 }, { "color": null, "has_workouts": false, "id": 4, "is_active": true, "is_active_for_user": true, "label": "Mountain Biking", "stopped_speed_threshold": 1 }, { "color": null, "has_workouts": false, "id": 5, "is_active": true, "is_active_for_user": true, "label": "Running", "stopped_speed_threshold": 0.1 }, { "color": null, "has_workouts": false, "id": 6, "is_active": true, "is_active_for_user": true, "label": "Walking", "stopped_speed_threshold": 0.1 } ] }, "status": "success" }
- Query Parameters:
check_workouts (boolean) – check if sport has workouts
- Request Headers:
Authorization – OAuth 2.0 Bearer Token if user is authenticated
- Status Codes:
200 OK –
success
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
- GET /api/sports/(int: sport_id)¶
Get a sport
Scope:
workouts:read
Example request:
GET /api/sports/1 HTTP/1.1 Content-Type: application/json
Example response:
success for non admin user:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "sports": [ { "color": null, "id": 1, "is_active": true, "is_active_for_user": true, "label": "Cycling (Sport)", "stopped_speed_threshold": 1 } ] }, "status": "success" }
sport not found:
HTTP/1.1 404 NOT FOUND Content-Type: application/json { "data": { "sports": [] }, "status": "not found" }
- 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
you do not have permissions, your account is suspended
404 Not Found –
sport not found
- PATCH /api/sports/(int: sport_id)¶
Update a sport.
Authenticated user must be an admin.
Scope:
workouts:write
Minimum role: Administrator
Example request:
PATCH /api/sports/1 HTTP/1.1 Content-Type: application/json
Example responses:
success:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "sports": [ { "color": null, "has_workouts": false, "id": 1, "is_active": false, "is_active_for_user": false, "label": "Cycling (Sport)", "stopped_speed_threshold": 1 } ] }, "status": "success" }
sport not found:
HTTP/1.1 404 NOT FOUND Content-Type: application/json { "data": { "sports": [] }, "status": "not found" }
- Parameters:
sport_id (integer) – sport id
- Request JSON Object:
is_active (string) – sport active status
- Request Headers:
Authorization – OAuth 2.0 Bearer Token
- Status Codes:
200 OK – sport updated
invalid payload
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
you do not have permissions
you do not have permissions, your account is suspended
404 Not Found –
sport not found
500 Internal Server Error –
error, please try again or contact the administrator