Users¶
-
GET
/api/users
¶ Get all users
Example request:
without parameters
GET /api/users HTTP/1.1 Content-Type: application/json
with some query parameters
GET /api/users?order_by=activities_count&par_page=5 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, "language": "en", "last_name": null, "location": null, "nb_activities": 6, "nb_sports": 3, "picture": false, "sports_list": [ 1, 4, 6 ], "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, "language": "fr", "last_name": null, "location": null, "nb_activities": 0, "nb_sports": 0, "picture": false, "sports_list": [], "timezone": "Europe/Paris", "total_distance": 0, "total_duration": "0:00:00", "username": "sam" } ] }, "status": "success" }
- Parameters
auth_user_id (integer) – authenticate user id (from JSON Web Token)
- Query Parameters
page (integer) – page if using pagination (default: 1)
per_page (integer) – number of users per page (default: 10, max: 50)
q (string) – query on user name
order_by (string) – sorting criteria (
username
,created_at
,activities_count
,admin
)order (string) – sorting order (default:
asc
)
- Request Headers
Authorization – OAuth 2.0 Bearer Token
- Status Codes
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)¶ Get single user details
Example request:
GET /api/users/admin 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, "language": "en", "last_name": null, "location": null, "nb_activities": 6, "nb_sports": 3, "picture": false, "sports_list": [ 1, 4, 6 ], "timezone": "Europe/Paris", "total_distance": 67.895, "total_duration": "6:50:27", "username": "admin" } ], "status": "success" }
- Parameters
auth_user_id (integer) – authenticate user id (from JSON Web Token)
user_name (integer) – user name
- Request Headers
Authorization – OAuth 2.0 Bearer Token
- Status Codes
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
¶ get user picture
Example request:
GET /api/users/admin/picture HTTP/1.1 Content-Type: application/json
Example response:
HTTP/1.1 200 OK Content-Type: image/jpeg
- Parameters
user_name (integer) – user name
- Status Codes
200 OK – success
User does not exist.
No picture.
-
PATCH
/api/users/
(user_name)¶ Update user to add admin rights
Only user with admin rights can modify another user
Example request:
PATCH api/users/<user_name> 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, "language": "en", "last_name": null, "location": null, "nb_activities": 6, "nb_sports": 3, "picture": false, "sports_list": [ 1, 4, 6 ], "timezone": "Europe/Paris", "total_distance": 67.895, "total_duration": "6:50:27", "username": "admin" } ], "status": "success" }
- Parameters
auth_user_id (integer) – authenticate user id (from JSON Web Token)
user_name (string) – user name
- Request JSON Object
admin (boolean) – does the user have administrator rights
- Request Headers
Authorization – OAuth 2.0 Bearer Token
- Status Codes
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.
User does not exist.
-
DELETE
/api/users/
(user_name)¶ Delete a user account
A user can only delete his own account
An admin can delete all accounts except his account if he’s the only one admin
Example request:
DELETE /api/users/john_doe HTTP/1.1 Content-Type: application/json
Example response:
HTTP/1.1 204 NO CONTENT Content-Type: application/json
- Parameters
auth_user_id (integer) – authenticate user id (from JSON Web Token)
user_name (string) – user name
- Request Headers
Authorization – OAuth 2.0 Bearer Token
- Status Codes
204 No Content – user account deleted
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.
User does not exist.
500 Internal Server Error – Error. Please try again or contact the administrator.