Statistiques#

GET /api/stats/(user_name)/by_time#

Obtenir des statistiques sur les séances d’entraînement pour un utilisateur par durée

Scope: workouts:read

Exemple de requêtes:

  • sans paramètres :

GET /api/stats/admin/by_time HTTP/1.1
  • avec des paramètres

GET /api/stats/admin/by_time?from=2018-01-01&to=2018-06-30&time=week
  HTTP/1.1

Exemple de réponse:

  • 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"
}
  • pas de séances :

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
      "statistics": {}
  },
  "status": "success"
}
Paramètres:
  • user_name (integer) – nom d’utilisateur

Paramètres de requête:
  • from (string) – date de début (format: %Y-%m-%d)

  • to (string) – date de fin (format: %Y-%m-%d)

  • time (string) – période de temps : - week: semaine commençant le dimanche - weekm: semaine commençant le lundi - month: mois - year: année (default)

En-têtes de requête:
Codes d’état:
  • 200 OKsuccess

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

  • 404 Not Founduser does not exist

GET /api/stats/(user_name)/by_sport#

Obtenir les statistiques des séances pour un utilisateur par sport.

Scope: workouts:read

Exemple de requêtes:

  • without parameters (get stats for all sports with workouts):

GET /api/stats/admin/by_sport HTTP/1.1
  • avec l’identifiant du sport

GET /api/stats/admin/by_sport?sport_id=1 HTTP/1.1

Exemple de réponse:

  • 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"
}
  • pas de séances :

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
      "statistics": {}
  },
  "status": "success"
}
Paramètres:
  • user_name (integer) – nom d’utilisateur

Paramètres de requête:
  • sport_id (integer) – identifiant du sport

En-têtes de requête:
Codes d’état:
  • 200 OKsuccess

  • 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#

Obtenir toutes les statistiques de l’application.

Scope: workouts:read

Exemple de requêtes:

GET /api/stats/all HTTP/1.1

Exemple de réponse:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "sports": 3,
    "uploads_dir_size": 1000,
    "users": 2,
    "workouts": 3,
  },
  "status": "success"
}
En-têtes de requête:
Codes d’état:
  • 200 OKsuccess

  • 401 Unauthorized

    • provide a valid auth token

    • signature expired, please log in again

    • invalid token, please log in again

  • 403 Forbiddenyou do not have permissions