Sports

GET /api/sports

Get all sports

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:
Status Codes:
  • 200 OKsuccess

  • 401 Unauthorized

    • 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:
Status Codes:
  • 200 OKsuccess

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

  • 404 Not Foundsport not found

PATCH /api/sports/(int: sport_id)

Update a sport.

Authenticated user must be an admin.

Scope: workouts:write

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:
Status Codes: