From fcebb7a3dfa1f8df258d74111584c700c46e1c4c Mon Sep 17 00:00:00 2001
From: Sam auth_user_id (integer) – authenticate user id auth_user_id (integer) – authenticate user id (from JSON Web Token) 200 OK – success 401 Unauthorized – invalid token Provide a valid auth token. Signature expired. Please log in again. Invalid token. Please log in again.
-
+
+
auth_user_id (integer) – authenticate user id
auth_user_id (integer) – authenticate user id (from JSON Web Token)
activity_id (integer) – activity id
200 OK – success
401 Unauthorized – Provide a valid auth token
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 – activity not found
auth_user_id (integer) – authenticate user id
auth_user_id (integer) – authenticate user id (from JSON Web Token)
File extension not allowed.
401 Unauthorized – invalid token
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
POST
/api/activities/no_gpx
¶
Post an activity without gpx file
Example request:
-POST /api/activities/ HTTP/1.1
+POST /api/activities/no_gpx HTTP/1.1
Content-Type: application/json
@@ -578,7 +593,7 @@
auth_user_id (integer) – authenticate user id
auth_user_id (integer) – authenticate user id (from JSON Web Token)
201 Created – activity created
400 Bad Request – invalid payload
401 Unauthorized – invalid token
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
auth_user_id (integer) – authenticate user id
auth_user_id (integer) – authenticate user id (from JSON Web Token)
activity_id (integer) – activity id
200 OK – activity updated
400 Bad Request – invalid payload
401 Unauthorized – invalid token
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
404 Not Found – activity not found
auth_user_id (integer) – authenticate user id
auth_user_id (integer) – authenticate user id (from JSON Web Token)
activity_id (integer) – activity id
204 No Content – activity deleted
401 Unauthorized – invalid token
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
404 Not Found – activity not found
500 Internal Server Error – Error. Please try again or contact the administrator.
auth_user_id (integer) – authenticate user id
map_id (string) – activity map id
Authorization – OAuth 2.0 Bearer Token
200 OK – success
401 Unauthorized – invalid token
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
404 Not Found – map does not exist
auth_user_id (integer) – authenticate user id
auth_user_id (integer) – authenticate user id (from JSON Web Token)
activity_id (integer) – activity id
200 OK – success
400 Bad Request – no gpx file for this activity
401 Unauthorized – invalid token
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
404 Not Found – activity not found
auth_user_id (integer) – authenticate user id
auth_user_id (integer) – authenticate user id (from JSON Web Token)
activity_id (integer) – activity id
200 OK – success
400 Bad Request – no gpx file for this activity
401 Unauthorized – invalid token
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
404 Not Found – activity not found
POST
/api/auth/register
¶
register a user
Example request:
-POST /auth/register HTTP/1.1
+POST /api/auth/register HTTP/1.1
Content-Type: application/json
@@ -196,7 +196,7 @@
POST
/api/auth/login
¶
user login
Example request:
-POST /auth/login HTTP/1.1
+POST /api/auth/login HTTP/1.1
Content-Type: application/json
@@ -248,7 +248,7 @@
GET
/api/auth/logout
¶
user logout
Example request:
-GET /auth/logout HTTP/1.1
+GET /api/auth/logout HTTP/1.1
Content-Type: application/json
@@ -297,7 +297,7 @@
GET
/api/auth/profile
¶
get authenticated user info
Example request:
-GET /auth/profile HTTP/1.1
+GET /api/auth/profile HTTP/1.1
Content-Type: application/json
@@ -337,7 +337,12 @@
200 OK – success.
401 Unauthorized – Provide a valid auth token.
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
POST
/api/auth/profile/edit
¶
edit authenticated user
Example request:
-POST /auth/profile/edit HTTP/1.1
+POST /api/auth/profile/edit HTTP/1.1
Content-Type: application/json
@@ -405,7 +410,12 @@
Password and password confirmation don’t match.
401 Unauthorized – Provide a valid auth token.
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
500 Internal Server Error – Error. Please try again or contact the administrator.
POST
/api/auth/picture
¶
update authenticated user picture
Example request:
-POST /auth/picture HTTP/1.1
+POST /api/auth/picture HTTP/1.1
Content-Type: multipart/form-data
@@ -469,7 +479,12 @@
File extension not allowed.
401 Unauthorized – Provide a valid auth token.
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
500 Internal Server Error – Error during picture update.
DELETE
/api/auth/picture
¶
delete authenticated user picture
Example request:
-DELETE /auth/picture HTTP/1.1
+DELETE /api/auth/picture HTTP/1.1
Content-Type: application/json
@@ -499,7 +514,12 @@
204 No Content – picture deleted
401 Unauthorized – Provide a valid auth token.
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
500 Internal Server Error – Error during picture deletion.
work in progress
GET
/api/records
¶Get all records for authenticated user
+Get all records for authenticated user.
+average speed (record_type: ‘AS’)
farest distance (record_type: ‘FD’)
longest duration (record_type: ‘LD’)
maximum speed (record_type: ‘MS’)
Example request:
+GET /api/records HTTP/1.1
+Content-Type: application/json
+
Example responses:
+returning records
HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "data": {
+ "records": [
+ {
+ "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
+ "activity_id": 4,
+ "id": 9,
+ "record_type": "AS",
+ "sport_id": 1,
+ "user_id": 1,
+ "value": 18
+ },
+ {
+ "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
+ "activity_id": 4,
+ "id": 10,
+ "record_type": "FD",
+ "sport_id": 1,
+ "user_id": 1,
+ "value": 18
+ },
+ {
+ "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
+ "activity_id": 7,
+ "id": 11,
+ "record_type": "LD",
+ "sport_id": 1,
+ "user_id": 1,
+ "value": "1:01:00"
+ },
+ {
+ "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
+ "activity_id": 4,
+ "id": 12,
+ "record_type": "MS",
+ "sport_id": 1,
+ "user_id": 1,
+ "value": 18
+ }
+ ]
+ },
+ "status": "success"
+}
+
no records
HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "data": {
+ "records": []
+ },
+ "status": "success"
+}
+
auth_user_id (integer) – authenticate user id (from JSON Web Token)
Authorization – OAuth 2.0 Bearer Token
200 OK – success
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
work in progress
GET
/api/sports
¶Get all sports
+Example request:
+GET /api/sports HTTP/1.1
+Content-Type: application/json
+
Example response:
+HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "data": {
+ "sports": [
+ {
+ "_can_be_deleted": false,
+ "id": 1,
+ "img": "/img/sports/cycling-sport.png",
+ "label": "Cycling (Sport)"
+ },
+ {
+ "_can_be_deleted": false,
+ "id": 2,
+ "img": "/img/sports/cycling-transport.png",
+ "label": "Cycling (Transport)"
+ },
+ {
+ "_can_be_deleted": false,
+ "id": 3,
+ "img": "/img/sports/hiking.png",
+ "label": "Hiking"
+ },
+ {
+ "_can_be_deleted": false,
+ "id": 4,
+ "img": "/img/sports/mountain-biking.png",
+ "label": "Mountain Biking"
+ },
+ {
+ "_can_be_deleted": false,
+ "id": 5,
+ "img": "/img/sports/running.png",
+ "label": "Running"
+ },
+ {
+ "_can_be_deleted": false,
+ "id": 6,
+ "img": "/img/sports/walking.png",
+ "label": "Walking"
+ }
+ ]
+ },
+ "status": "success"
+}
+
auth_user_id (integer) – authenticate user id (from JSON Web Token)
Authorization – OAuth 2.0 Bearer Token
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
HTTP/1.1 200 OK
+Content-Type: application/json
-
POST
/api/sports
¶Post a sport
-sport not found
auth_user_id (integer) – authenticate user id (from JSON Web Token)
sport_id (integer) – sport id
Authorization – OAuth 2.0 Bearer Token
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
work in progress
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"
+}
+
auth_user_id (integer) – authenticate user id (from JSON Web Token)
user_id (integer) – user id
sport_id (integer) – sport id
Authorization – OAuth 2.0 Bearer Token
200 OK – success
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
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"
+}
+
auth_user_id (integer) – authenticate user id (from JSON Web Token)
user_id (integer) – user id
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)
Authorization – OAuth 2.0 Bearer Token
200 OK – success
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
User does not exist.
work in progress
GET
/api/users
¶Get all users
+Example request:
+GET /api/users HTTP/1.1
+Content-Type: application/json
+
Example response:
+HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "data": {
+ "users": [
+ {
+ "admin": true,
+ "bio": null,
+ "birth_date": null,
+ "created_at": "Sun, 14 Jul 2019 14:09:58 GMT",
+ "email": "admin@example.com",
+ "first_name": null,
+ "id": 1,
+ "last_name": null,
+ "location": null,
+ "nb_activities": 6,
+ "nb_sports": 3,
+ "picture": false,
+ "timezone": "Europe/Paris",
+ "total_distance": 67.895,
+ "total_duration": "6:50:27",
+ "username": "admin"
+ },
+ {
+ "admin": false,
+ "bio": null,
+ "birth_date": null,
+ "created_at": "Sat, 20 Jul 2019 11:27:03 GMT",
+ "email": "sam@example.com",
+ "first_name": null,
+ "id": 2,
+ "last_name": null,
+ "location": null,
+ "nb_activities": 0,
+ "nb_sports": 0,
+ "picture": false,
+ "timezone": "Europe/Paris",
+ "total_distance": 0,
+ "total_duration": "0:00:00",
+ "username": "sam"
+ }
+ ]
+ },
+ "status": "success"
+}
+
auth_user_id (integer) – authenticate user id (from JSON Web Token)
Authorization – OAuth 2.0 Bearer Token
200 OK – success
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
GET
/api/users/
(user_id)¶Get single user details
+Example request:
+GET /api/users/1 HTTP/1.1
+Content-Type: application/json
+
Example response:
+HTTP/1.1 200 OK
+Content-Type: application/json
+
+{
+ "data": {
+ "admin": true,
+ "bio": null,
+ "birth_date": null,
+ "created_at": "Sun, 14 Jul 2019 14:09:58 GMT",
+ "email": "admin@example.com",
+ "first_name": null,
+ "id": 1,
+ "last_name": null,
+ "location": null,
+ "nb_activities": 6,
+ "nb_sports": 3,
+ "picture": false,
+ "timezone": "Europe/Paris",
+ "total_distance": 67.895,
+ "total_duration": "6:50:27",
+ "username": "admin"
+ },
+ "status": "success"
+}
+
auth_user_id (integer) – authenticate user id (from JSON Web Token)
user_id (integer) – user id
Authorization – OAuth 2.0 Bearer Token
200 OK – success
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
User does not exist
GET
/api/users/
(user_id)/picture
¶get user picture
+Example request:
+GET /api/users/1/picture HTTP/1.1
+Content-Type: application/json
+
Example response:
+HTTP/1.1 200 OK
+Content-Type: image/jpeg
+
auth_user_id (integer) – authenticate user id (from JSON Web Token)
user_id (integer) – user id
200 OK – success
Provide a valid auth token.
Signature expired. Please log in again.
Invalid token. Please log in again.
User does not exist
No picture.
POST /api/auth/register
POST /api/sports
DELETE /api/auth/picture
DELETE /api/sports/(int:sport_id)
PATCH /api/activities/(int:activity_id)
PATCH /api/sports/(int:sport_id)