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": {
          "average_speed": 4.48,
          "nb_workouts": 2,
          "total_ascent": 203.0,
          "total_ascent": 156.0,
          "total_distance": 15.282,
          "total_duration": 12341
        }
      },
      "2019": {
        "1": {
          "average_speed": 16.99,
          "nb_workouts": 3,
          "total_ascent": 150.0,
          "total_ascent": 178.0,
          "total_distance": 47,
          "total_duration": 9960
        },
        "2": {
          "average_speed": 15.95,
          "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:
  • 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 Sunday

    • weekm: week starting Monday

    • month: month

    • year: year (default)

Request Headers:
Status Codes:
  • 200 OK – success

  • 401 Unauthorized

    • 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

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": {
        "average_speed": 16.99,
        "nb_workouts": 3,
        "total_ascent": 150.0,
        "total_ascent": 178.0,
        "total_distance": 47,
        "total_duration": 9960
      },
      "2": {
        "average_speed": 15.95,
        "nb_workouts": 1,
        "total_ascent": 46.0,
        "total_ascent": 78.0,
        "total_distance": 5.613,
        "total_duration": 1267
      },
      "3": {
        "average_speed": 4.46,
        "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:
  • user_name (integer) – user name

Query Parameters:
  • sport_id (integer) – sport id

Request Headers:
Status Codes:
  • 200 OK – success

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

  • 404 Not Found

    • 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"
}
Request Headers:
Status Codes:
  • 200 OK – success

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

  • 403 Forbidden – you do not have permissions