Utilisateurs¶
- GET /api/users¶
Obtenir tous les utilisateurs (quel que soit le statut de leur compte), si l’utilisateur authentifié a des droits d’administration.
Ne renvoie les préférences de l’utilisateur que pour l’utilisateur authentifié.
Scope :
users:read
Exemple de requête :
sans paramètres :
GET /api/users HTTP/1.1 Content-Type: application/json
avec quelques paramètres de requête :
GET /api/users?order_by=workouts_count&par_page=5 HTTP/1.1 Content-Type: application/json
Exemple de réponse :
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, "is_admin": true, "imperial_units": false, "language": "en", "last_name": null, "location": null, "nb_sports": 3, "nb_workouts": 6, "picture": false, "records": [ { "id": 9, "record_type": "AS", "sport_id": 1, "user": "admin", "value": 18, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "id": 10, "record_type": "FD", "sport_id": 1, "user": "admin", "value": 18, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "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": 11, "record_type": "LD", "sport_id": 1, "user": "admin", "value": "1:01:00", "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "id": 12, "record_type": "MS", "sport_id": 1, "user": "admin", "value": 18, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" } ], "sports_list": [ 1, 4, 6 ], "timezone": "Europe/Paris", "total_distance": 67.895, "total_duration": "6:50:27", "username": "admin", "weekm": false }, { "admin": false, "bio": null, "birth_date": null, "created_at": "Sat, 20 Jul 2019 11:27:03 GMT", "email": "sam@example.com", "first_name": null, "is_admin": false, "language": "fr", "last_name": null, "location": null, "nb_sports": 0, "nb_workouts": 0, "picture": false, "records": [], "sports_list": [], "timezone": "Europe/Paris", "total_distance": 0, "total_duration": "0:00:00", "username": "sam" } ] }, "status": "success" }
- Paramètres de requête:
page (integer) – page si pagination (par défaut : 1)
per_page (integer) – nombre d’utilisateurs par page (par défaut : 10, max : 50)
q (string) – requête sur le nom de l’utilisateur
order (string) – ordre de tri :
asc
,desc
(par défaut :asc
)order_by (string) – critères de tri :
username
,created_at
,workouts_count
,admin
,is_active
(par défaut :username
)
- 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
- GET /api/users/(user_name)¶
Obtenir les information d’un utilisateur. Seul l’utilisateur disposant des droits d’administrateur peut obtenir les informations des autres utilisateurs.
Ne renvoie les préférences de l’utilisateur que pour l’utilisateur authentifié.
Scope :
users:read
Exemple de requête :
GET /api/users/admin HTTP/1.1 Content-Type: application/json
Exemple de réponse :
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, "imperial_units": false, "is_admin": true, "language": "en", "last_name": null, "location": null, "nb_sports": 3, "nb_workouts": 6, "picture": false, "records": [ { "id": 9, "record_type": "AS", "sport_id": 1, "user": "admin", "value": 18, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "id": 10, "record_type": "FD", "sport_id": 1, "user": "admin", "value": 18, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "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": 11, "record_type": "LD", "sport_id": 1, "user": "admin", "value": "1:01:00", "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "id": 12, "record_type": "MS", "sport_id": 1, "user": "admin", "value": 18, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" } ], "sports_list": [ 1, 4, 6 ], "timezone": "Europe/Paris", "total_distance": 67.895, "total_duration": "6:50:27", "username": "admin" } ], "status": "success" }
- Paramètres:
user_name (integer) – nom de l’utilisateur
- 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
user does not exist
- GET /api/users/(user_name)/picture¶
obtenir l’image de l’utilisateur
Exemple de requête :
GET /api/users/admin/picture HTTP/1.1 Content-Type: application/json
Exemple de réponse :
HTTP/1.1 200 OK Content-Type: image/jpeg
- Paramètres:
user_name (integer) – nom de l’utilisateur
- Codes d’état:
200 OK –
success
user does not exist
No picture.
- PATCH /api/users/(user_name)¶
Mise à jour du compte utilisateur.
ajouter/supprimer des droits d’administration (quel que soit le statut du compte d’utilisateur)
réinitialiser le mot de passe (et envoyer un courriel pour mettre à jour le mot de passe de l’utilisateur, si l’envoi activé)
mettre à jour l’adresse électronique de l’utilisateur (et envoyer un message à la nouvelle adresse électronique de l’utilisateur, si l’envoi est activé)
activer le compte d’un utilisateur inactif
Seul l’utilisateur ayant des droits d’administration peut modifier un autre utilisateur.
Scope :
users:write
Exemple de requête :
PATCH /api/users/<user_name> HTTP/1.1 Content-Type: application/json
Exemple de réponse :
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, "imperial_units": false, "is_active": true, "language": "en", "last_name": null, "location": null, "nb_workouts": 6, "nb_sports": 3, "picture": false, "records": [ { "id": 9, "record_type": "AS", "sport_id": 1, "user": "admin", "value": 18, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "id": 10, "record_type": "FD", "sport_id": 1, "user": "admin", "value": 18, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "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": 11, "record_type": "LD", "sport_id": 1, "user": "admin", "value": "1:01:00", "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" }, { "id": 12, "record_type": "MS", "sport_id": 1, "user": "admin", "value": 18, "workout_date": "Sun, 07 Jul 2019 08:00:00 GMT", "workout_id": "hvYBqYBRa7wwXpaStWR4V2" } ], "sports_list": [ 1, 4, 6 ], "timezone": "Europe/Paris", "total_distance": 67.895, "total_duration": "6:50:27", "username": "admin" } ], "status": "success" }
- Paramètres:
user_name (string) – nom de l’utilisateur
- Objet JSON de requête:
activate (boolean) – activer le compte utilisateur
admin (boolean) – l’utilisateur dispose-t-il de droits d’administration
new_email (boolean) – nouvelle adresse électronique de l’utilisateur
reset_password (boolean) – réinitialiser le mot de passe de l’utilisateur
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
200 OK –
success
invalid payload
valid email must be provided
new email must be different than current email
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 –
user does not exist
500 Internal Server Error –
error, please try again or contact the administrator
- DELETE /api/users/(user_name)¶
Supprimer un compte utilisateur.
Un utilisateur ne peut supprimer que son propre compte.
Un administrateur peut supprimer tous les comptes sauf le sien s’il est le seul administrateur.
Scope :
users:write
Exemple de requête :
DELETE /api/users/john_doe HTTP/1.1 Content-Type: application/json
Exemple de réponse :
HTTP/1.1 204 NO CONTENT Content-Type: application/json
- Paramètres:
user_name (string) – nom de l’utilisateur
- En-têtes de requête:
Authorization – Jeton “OAuth 2.0 Bearer”
- Codes d’état:
204 No Content – compte de l’utilisateur supprimé
provide a valid auth token
signature expired, please log in again
invalid token, please log in again
you do not have permissions
you can not delete your account, no other user has admin rights
404 Not Found –
user does not exist
500 Internal Server Error –
error, please try again or contact the administrator