Sports¶
-
GET
/api/sports
¶ Get all sports
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": [ { "id": 1, "img": "/img/sports/cycling-sport.png", "is_active": true, "label": "Cycling (Sport)" }, { "id": 2, "img": "/img/sports/cycling-transport.png", "is_active": true, "label": "Cycling (Transport)" }, { "id": 3, "img": "/img/sports/hiking.png", "is_active": true, "label": "Hiking" }, { "id": 4, "img": "/img/sports/mountain-biking.png", "is_active": true, "label": "Mountain Biking" }, { "id": 5, "img": "/img/sports/running.png", "is_active": true, "label": "Running" }, { "id": 6, "img": "/img/sports/walking.png", "is_active": true, "label": "Walking" } ] }, "status": "success" }
for admin user :
HTTP/1.1 200 OK Content-Type: application/json { "data": { "sports": [ { "has_workouts": true, "id": 1, "img": "/img/sports/cycling-sport.png", "is_active": true, "label": "Cycling (Sport)" }, { "has_workouts": false, "id": 2, "img": "/img/sports/cycling-transport.png", "is_active": true, "label": "Cycling (Transport)" }, { "has_workouts": false, "id": 3, "img": "/img/sports/hiking.png", "is_active": true, "label": "Hiking" }, { "has_workouts": false, "id": 4, "img": "/img/sports/mountain-biking.png", "is_active": true, "label": "Mountain Biking" }, { "has_workouts": false, "id": 5, "img": "/img/sports/running.png", "is_active": true, "label": "Running" }, { "has_workouts": false, "id": 6, "img": "/img/sports/walking.png", "is_active": true, "label": "Walking" } ] }, "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.
-
GET
/api/sports/
(int: sport_id)¶ Get a sport
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": [ { "id": 1, "img": "/img/sports/cycling-sport.png", "is_active": true, "label": "Cycling (Sport)" } ] }, "status": "success" }
success for admin user :
HTTP/1.1 200 OK Content-Type: application/json { "data": { "sports": [ { "has_workouts": false, "id": 1, "img": "/img/sports/cycling-sport.png", "is_active": true, "label": "Cycling (Sport)" } ] }, "status": "success" }
sport not found
HTTP/1.1 404 NOT FOUND Content-Type: application/json { "data": { "sports": [] }, "status": "not found" }
- Parameters
auth_user_id (integer) – authenticate user id (from JSON Web Token)
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.
404 Not Found – sport not found
-
PATCH
/api/sports/
(int: sport_id)¶ Update a sport Authenticated user must be an admin
Example request:
PATCH /api/sports/1 HTTP/1.1 Content-Type: application/json
Example response:
success
HTTP/1.1 200 OK Content-Type: application/json { "data": { "sports": [ { "has_workouts": false, "id": 1, "img": "/img/sports/cycling-sport.png", "is_active": false, "label": "Cycling (Sport)" } ] }, "status": "success" }
sport not found
HTTP/1.1 404 NOT FOUND Content-Type: application/json { "data": { "sports": [] }, "status": "not found" }
- Parameters
auth_user_id (integer) – authenticate user id (from JSON Web Token)
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
400 Bad Request – invalid payload
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
403 Forbidden – You do not have permissions.
404 Not Found – sport not found