Statistics

GET /api/stats/(int: user_id)/by_sport

Get activities statistics for a user by sport

Example requests:

  • without parameters (get stats for all sports with activities)

GET /api/stats/1/by_sport HTTP/1.1
  • with sport id

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

Example responses:

  • success

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

{
  "data": {
    "statistics": {
      "1": {
        "nb_activities": 3,
        "total_distance": 47,
        "total_duration": 9960
      },
      "2": {
        "nb_activities": 1,
        "total_distance": 5.613,
        "total_duration": 1267
      },
      "3": {
        "nb_activities": 2,
        "total_distance": 15.282,
        "total_duration": 12341
      }
    }
  },
  "status": "success"
}
  • no activities

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

{
  "data": {
      "statistics": {}
  },
  "status": "success"
}
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • user_id (integer) – user id

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/(int: user_id)/by_time

Get activities statistics for a user by time

Example requests:

  • without parameters

GET /api/stats/1/by_time HTTP/1.1
  • with parameters

GET /api/stats/1/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": {
          "nb_activities": 2,
          "total_distance": 15.282,
          "total_duration": 12341
        }
      },
      "2019": {
        "1": {
          "nb_activities": 3,
          "total_distance": 47,
          "total_duration": 9960
        },
        "2": {
          "nb_activities": 1,
          "total_distance": 5.613,
          "total_duration": 1267
        }
      }
    }
  },
  "status": "success"
}
  • no activities

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

{
  "data": {
      "statistics": {}
  },
  "status": "success"
}
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • user_id (integer) – user id

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/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": {
    "activities": 3,
    "sports": 3,
    "users": 2
  },
  "status": "success"
}
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

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.