Séances#
- GET /api/workouts#
Obtenir les séances de l’utilisateur authentifié.
Scope:
workouts:read
Exemple de requêtes:
sans paramètres :
GET /api/workouts/ HTTP/1.1
avec quelques paramètres de requête :
GET /api/workouts?from=2019-07-02&to=2019-07-31&sport_id=1 HTTP/1.1
Exemple de réponse:
renvoyant au moins une séance :
HTTP/1.1 200 OK Content-Type: application/json { "data": { "workouts": [ { "ascent": null, "ave_speed": 10.0, "bounds": [], "creation_date": "Sun, 14 Jul 2019 13:51:01 GMT", "descent": null, "distance": 10.0, "duration": "0:17:04", "id": "kjxavSTUrJvoAh2wvCeGEF", "map": null, "max_alt": null, "max_speed": 10.0, "min_alt": null, "modification_date": null, "moving": "0:17:04", "next_workout": 3, "notes": null, "pauses": null, "previous_workout": null, "records": [ { "id": 4, "record_type": "MS", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 13, "record_type": "HA", "sport_id": 1, "user": "Sam", "value": 43.97, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "id": 3, "record_type": "LD", "sport_id": 1, "user": "admin", "value": "0:17:04", "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 2, "record_type": "FD", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 1, "record_type": "AS", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" } ], "segments": [], "sport_id": 1, "title": null, "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT" } ] }, "status": "success" }
renvoyant aucune séance
HTTP/1.1 200 OK Content-Type: application/json { "data": { "workouts": [] }, "status": "success" }
- Paramètres de requête:
page (integer) – page si pagination (par défaut : 1)
per_page (integer) – nombre d’entraînements par page (par défaut : 5, max : 100)
sport_id (integer) – identifiant du sport
title (string) – une partie (ou la totalité) du titre de la séance, la correspondance entre les titres ne tient pas compte des majuscules et des minuscules
from (string) – date de début (format:
%Y-%m-%d
)to (string) – date de fin (format:
%Y-%m-%d
)distance_from (float) – distance minimale
distance_to (float) – distance maximale
duration_from (string) – durée minimale (format:
%H:%M
)duration_to (string) – distance maximale (format:
%H:%M
)ave_speed_from (float) – vitesse moyenne minimale
ave_speed_to (float) – vitesse moyenne maximale
max_speed_from (float) – vitesse max. minimale
max_speed_to (float) – vitesse max. maximale
order (string) – ordre de tri :
asc
,desc
(par défaut :desc
)order_by (string) – sorting criteria:
ave_speed
,distance
,duration
,workout_date
(default:workout_date
)
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
200 OK –
success
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
- GET /api/workouts/(string: workout_short_id)#
Obtenir une séance.
Scope:
workouts:read
Exemple de requête:
GET /api/workouts/kjxavSTUrJvoAh2wvCeGEF HTTP/1.1
Exemple de réponse:
success:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "workouts": [ { "ascent": null, "ave_speed": 16, "bounds": [], "creation_date": "Sun, 14 Jul 2019 18:57:14 GMT", "descent": null, "distance": 12, "duration": "0:45:00", "id": "kjxavSTUrJvoAh2wvCeGEF", "map": null, "max_alt": null, "max_speed": 16, "min_alt": null, "modification_date": "Sun, 14 Jul 2019 18:57:22 GMT", "moving": "0:45:00", "next_workout": 4, "notes": "workout without gpx", "pauses": null, "previous_workout": 3, "records": [], "segments": [], "sport_id": 1, "title": "biking on sunday morning", "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false, "workout_date": "Sun, 07 Jul 2019 07:00:00 GMT" } ] }, "status": "success" }
séance non trouvé :
HTTP/1.1 404 NOT FOUND Content-Type: application/json { "data": { "workouts": [] }, "status": "not found" }
- Paramètres:
workout_short_id (string) – identifiant court de la séance
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
200 OK –
success
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 –
workout not found
- GET /api/workouts/(string: workout_short_id)/gpx#
Obtenir un fichier gpx pour une séance affichée sur une carte avec Leaflet.
Scope:
workouts:read
Exemple de requête:
GET /api/workouts/kjxavSTUrJvoAh2wvCeGEF/gpx HTTP/1.1 Content-Type: application/json
Exemple de réponse:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "gpx": "gpx file content" }, "message": "", "status": "success" }
- Paramètres:
workout_short_id (string) – identifiant court de la séance
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
200 OK –
success
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
workout not found
no gpx file for this workout
500 Internal Server Error –
error, please try again or contact the administrator
- GET /api/workouts/(string: workout_short_id)/chart_data#
Récupérer les données d’une séance avec gpx pour les afficher avec Chart.js
Scope:
workouts:read
Exemple de requête:
GET /api/workouts/kjxavSTUrJvoAh2wvCeGEF/chart HTTP/1.1 Content-Type: application/json
Exemple de réponse:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "chart_data": [ { "distance": 0, "duration": 0, "elevation": 279.4, "latitude": 51.5078118, "longitude": -0.1232004, "speed": 8.63, "time": "Fri, 14 Jul 2017 13:44:03 GMT" }, { "distance": 7.5, "duration": 7380, "elevation": 280, "latitude": 51.5079733, "longitude": -0.1234538, "speed": 6.39, "time": "Fri, 14 Jul 2017 15:47:03 GMT" } ] }, "message": "", "status": "success" }
- Paramètres:
workout_short_id (string) – identifiant court de la séance
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
200 OK –
success
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
workout not found
no gpx file for this workout
500 Internal Server Error –
error, please try again or contact the administrator
- GET /api/workouts/(string: workout_short_id)/chart_data/segment/(int: segment_id)#
Récupérer les données d’une séance avec gpx pour les afficher avec Chart.js
Scope:
workouts:read
Exemple de requête:
GET /api/workouts/kjxavSTUrJvoAh2wvCeGEF/chart/segment/0 HTTP/1.1 Content-Type: application/json
Exemple de réponse:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "chart_data": [ { "distance": 0, "duration": 0, "elevation": 279.4, "latitude": 51.5078118, "longitude": -0.1232004, "speed": 8.63, "time": "Fri, 14 Jul 2017 13:44:03 GMT" }, { "distance": 7.5, "duration": 7380, "elevation": 280, "latitude": 51.5079733, "longitude": -0.1234538, "speed": 6.39, "time": "Fri, 14 Jul 2017 15:47:03 GMT" } ] }, "message": "", "status": "success" }
- Paramètres:
workout_short_id (string) – identifiant court de la séance
segment_id (integer) – identifiant du segment
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
200 OK –
success
400 Bad Request –
no gpx file for this workout
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
404 Not Found –
workout not found
500 Internal Server Error –
error, please try again or contact the administrator
- GET /api/workouts/(string: workout_short_id)/gpx/segment/(int: segment_id)#
Obtenir un fichier gpx pour le segment d’une séance pour l’afficher sur la carte avec Leaflet.
Scope:
workouts:read
Exemple de requête:
GET /api/workouts/kjxavSTUrJvoAh2wvCeGEF/gpx/segment/0 HTTP/1.1 Content-Type: application/json
Exemple de réponse:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "gpx": "gpx file content" }, "message": "", "status": "success" }
- Paramètres:
workout_short_id (string) – identifiant court de la séance
segment_id (integer) – identifiant du segment
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
200 OK –
success
400 Bad Request –
no gpx file for this workout
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
404 Not Found –
workout not found
500 Internal Server Error –
error, please try again or contact the administrator
- GET /api/workouts/map/(map_id)#
Obtenir l’image de la carte pour les séances avec gpx.
Exemple de requête:
GET /api/workouts/map/fa33f4d996844a5c73ecd1ae24456ab8?1563529507772 HTTP/1.1
Exemple de réponse:
HTTP/1.1 200 OK Content-Type: image/png
- Paramètres:
map_id (string) – identifiant de la carte de la séance
- Codes d’état:
200 OK –
success
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
404 Not Found –
map does not exist
500 Internal Server Error –
error, please try again or contact the administrator
- GET /api/workouts/map_tile/(s)/(z)/(x)/(y).png#
Obtenir une tuile de la carte à partir du serveur de tuiles.
Exemple de requête:
GET /api/workouts/map_tile/c/13/4109/2930.png HTTP/1.1
Exemple de réponse:
HTTP/1.1 200 OK Content-Type: image/png
- Paramètres:
s (string) – sous-domaine
z (string) – zoom
x (string) – index de la tuile sur l’axe x de la carte
y (string) – index de la tuile sur l’axe y de la carte
Les codes d’état sont des codes d’état renvoyés par le serveur de tuiles.
- GET /api/workouts/(string: workout_short_id)/gpx/download#
Télécharger le fichier gpx.
Scope:
workouts:read
Exemple de requête:
GET /api/workouts/kjxavSTUrJvoAh2wvCeGEF/gpx/download HTTP/1.1
Exemple de réponse:
HTTP/1.1 200 OK Content-Type: application/gpx+xml
- Paramètres:
workout_short_id (string) – identifiant court de la séance
- Codes d’état:
200 OK –
success
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
workout not found
no gpx file for workout
- POST /api/workouts#
Créer une séance à partir d’un fichier gpx.
Scope:
workouts:write
Exemple de requête:
POST /api/workouts/ HTTP/1.1 Content-Type: multipart/form-data
Exemple de réponse:
HTTP/1.1 201 CREATED Content-Type: application/json { "data": { "workouts": [ { "ascent": null, "ave_speed": 10.0, "bounds": [], "creation_date": "Sun, 14 Jul 2019 13:51:01 GMT", "descent": null, "distance": 10.0, "duration": "0:17:04", "id": "kjxavSTUrJvoAh2wvCeGEF", "map": null, "max_alt": null, "max_speed": 10.0, "min_alt": null, "modification_date": null, "moving": "0:17:04", "next_workout": 3, "notes": null, "pauses": null, "previous_workout": null, "records": [ { "id": 4, "record_type": "MS", "sport_id": 1, "user": "admin", "value": 10., "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 3, "record_type": "LD", "sport_id": 1, "user": "admin", "value": "0:17:04", "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF", }, { "id": 2, "record_type": "FD", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 1, "record_type": "AS", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" } ], "segments": [], "sport_id": 1, "title": null, "user": "admin", "weather_end": null, "weather_start": null, "with_gpx": false, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT" } ] }, "status": "success" }
- Paramètres de la forme:
file – fichier gpx (extensions autorisées : .gpx, .zip)
data – l’identifiant du sport et les notes (exemple :
{"sport_id": 1, "notes": ""}
). Les guillemets doubles dans les notes doivent être échappés.
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
201 Created – séance créée
invalid payload
no file part
no selected file
file extension not allowed
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
413 Request Entity Too Large –
error during picture update: file size exceeds 1.0MB
500 Internal Server Error –
error, please try again or contact the administrator
- POST /api/workouts/no_gpx#
Créer une séance sans fichier gpx.
Scope:
workouts:write
Exemple de requête:
POST /api/workouts/no_gpx HTTP/1.1 Content-Type: application/json
Exemple de réponse:
HTTP/1.1 201 CREATED Content-Type: application/json { "data": { "workouts": [ { "ascent": null, "ave_speed": 10.0, "bounds": [], "creation_date": "Sun, 14 Jul 2019 13:51:01 GMT", "descent": null, "distance": 10.0, "duration": "0:17:04", "map": null, "max_alt": null, "max_speed": 10.0, "min_alt": null, "modification_date": null, "moving": "0:17:04", "next_workout": 3, "notes": null, "pauses": null, "previous_workout": null, "records": [ { "id": 4, "record_type": "MS", "sport_id": 1, "user": "admin", "value": 10., "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 3, "record_type": "LD", "sport_id": 1, "user": "admin", "value": "0:17:04", "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 2, "record_type": "FD", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 1, "record_type": "AS", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" } ], "segments": [], "sport_id": 1, "title": null, "user": "admin", "uuid": "kjxavSTUrJvoAh2wvCeGEF" "weather_end": null, "weather_start": null, "with_gpx": false, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT" } ] }, "status": "success" }
- Objet JSON de requête:
ascent (float) – workout ascent (not mandatory, must be provided with descent)
descent (float) – dénivelé négatif (non obligatoire, à fournir avec le dénivelé positif)
distance (float) – distance de la séance en km
duration (integer) – durée de la séance en secondes
notes (string) – notes (non obligatoire)
sport_id (integer) – identifiant du sport de la séance
title (string) – titre de la séance (non obligatoire)
workout_date (string) – date de la séance, dans le fuseau horaire de l’utilisateur (format:
%Y-%m-%d %H:%M
)
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
201 Created – séance créée
400 Bad Request –
invalid payload
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
- PATCH /api/workouts/(string: workout_short_id)#
Mettre à jour une séance
Scope:
workouts:write
Exemple de requête:
PATCH /api/workouts/1 HTTP/1.1 Content-Type: application/json
Exemple de réponse:
HTTP/1.1 200 OK Content-Type: application/json { "data": { "workouts": [ { "ascent": null, "ave_speed": 10.0, "bounds": [], "creation_date": "Sun, 14 Jul 2019 13:51:01 GMT", "descent": null, "distance": 10.0, "duration": "0:17:04", "map": null, "max_alt": null, "max_speed": 10.0, "min_alt": null, "modification_date": null, "moving": "0:17:04", "next_workout": 3, "notes": null, "pauses": null, "previous_workout": null, "records": [ { "id": 4, "record_type": "MS", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 3, "record_type": "LD", "sport_id": 1, "user": "admin", "value": "0:17:04", "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF" }, { "id": 2, "record_type": "FD", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF", }, { "id": 1, "record_type": "AS", "sport_id": 1, "user": "admin", "value": 10.0, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT", "workout_id": "kjxavSTUrJvoAh2wvCeGEF", } ], "segments": [], "sport_id": 1, "title": null, "user": "admin", "uuid": "kjxavSTUrJvoAh2wvCeGEF" "weather_end": null, "weather_start": null, "with_gpx": false, "workout_date": "Mon, 01 Jan 2018 00:00:00 GMT" } ] }, "status": "success" }
- Paramètres:
workout_short_id (string) – identifiant court de la séance
- Objet JSON de requête:
ascent (float) – dénivelé positif de la séance (seulement pour les séances sans gpx, doit être fourni avec le dénivelé négatif)
descent (float) – dénivelé négatif de la séance (seulement pour les séances sans gpx, doit être fourni avec le dénivelé positif)
distance (float) – distance de la séance en km (seulement pour les séances sans gpx)
duration (integer) – durée de la séance en secondes (seulement pour les séances sans gpx)
notes (string) – notes
sport_id (integer) – identifiant du sport de la séance
title (string) – titre de la séance
workout_date (string) – date de la séance dans le fuseau horaire de l’utilisateur (format:
%Y-%m-%d %H:%M
) (seulement pour les séances sans gpx)
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
200 OK – séance mise à jour
400 Bad Request –
invalid payload
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
404 Not Found –
workout not found
500 Internal Server Error –
error, please try again or contact the administrator
- DELETE /api/workouts/(string: workout_short_id)#
Supprimer la séance
Scope:
workouts:write
Exemple de requête:
DELETE /api/workouts/kjxavSTUrJvoAh2wvCeGEF HTTP/1.1 Content-Type: application/json
Exemple de réponse:
HTTP/1.1 204 NO CONTENT Content-Type: application/json
- Paramètres:
workout_short_id (string) – identifiant court de la séance
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
204 No Content – séance supprimée
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
404 Not Found –
workout not found
500 Internal Server Error –
error, please try again or contact the administrator