User API Documentation - bounswe/2021SpringGroup2 GitHub Wiki
POST 'api/user/create/'
-
Author: Ege Can Kaya
-
Definition: Allows a user to register
-
Example Response Value:
{ "email": "[email protected]", "username": "egekaya" }
-
Example Failure Value:
{ "username": [ "This field is required." ], "password": [ "This field is required." ] }
-
Parameters
Parameter Description Parameter Type Data Type username Username of registering user Body String email Email address of registering user Body String password Password of registering user Body String -
Response Messages
- 201: Created.
- 400: Bad request.
POST 'api/token/obtain/'
-
Author: Ege Can Kaya
-
Definition: Takes a set of user credentials and returns an access and refresh JSON web token pair to prove the authentication of those credentials.
-
Example Response Value:
{ "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYzODAzMzQ0OCwiaWF0IjoxNjM2ODIzODQ4LCJqdGkiOiJiNDkxZjIwZjU2OTY0YTJiYjI2OTIyNWJjMmZkNTc3YSIsInVzZXJfaWQiOjR9.tCGeBNzTXXBA8fTC2eqxyy2wfa1tYEN8nL0mSCzftP0", "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjM2ODI0MTQ4LCJpYXQiOjE2MzY4MjM4NDgsImp0aSI6ImY0ZWIyNDY5ZWIwZDQyMDQ4NzI1NTAyNDQ5YjZlYTM2IiwidXNlcl9pZCI6NH0.HgN9BIi3F-1lnio_s32IHdsHNDUlAuNcWaE_s9A11vY" }
-
Example Failure Value:
{ "detail": "No active account found with the given credentials" }
-
Parameters
Parameter Description Parameter Type Data Type username Username Body String password Password Body String -
Response Messages
- 200: OK.
- 401: Unauthorized.
POST 'api/token/refresh/'
-
Author: Ege Can Kaya
-
Definition: Takes a refresh type JSON web token and returns an access type JSON web token if the refresh token is valid.
-
Example Response Value:
{ "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjM2ODI0NDUxLCJpYXQiOjE2MzY4MjM4NDgsImp0aSI6IjY3ZTRlZDE2NzQyYTQyYTZiOGY2OTBiZTFmMTUzZjQ1IiwidXNlcl9pZCI6NH0.J9WhNq04miuDSABsobZtPHS5drcXxcq0eQE6MH44-zU", "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYzODAzMzc1MSwiaWF0IjoxNjM2ODI0MTUxLCJqdGkiOiI0NjQ0MDFjNGY2ZjA0OTA3YjZlZTA3NDA0ZmQ0ZmI0MiIsInVzZXJfaWQiOjR9.r4q3jpcilwT6bqXupFqhSnu7pc58IzPNJXilnfwhwwM" }
-
Example Failure Value:
{ "detail": "Token is invalid or expired", "code": "token_not_valid" }
-
Parameters
Parameter Description Parameter Type Data Type Refresh Refresh type JWT token Body String -
Response Messages
- 200: OK.
- 401: Unauthorized.
POST 'api/password/reset/'
-
Author: Ege Can Kaya
-
Definition: Provides a method to request a password reset token based on an e-mail address
-
Example Response Value:
{ "status": "OK" }
-
Example Failure Value:
{ "email": [ "We couldn't find an account associated with that email. Please try a different e-mail address." ] }
-
Parameters
Parameter Description Parameter Type Data Type Email Email address of user trying to reset their password Body String -
Response Messages
- 200: OK.
- 400: Bad request.
POST 'api/password/reset/confirm/'
-
Author: Ege Can Kaya
-
Definition: Provides a method to reset a password based on a unique token
-
Example Response Value:
{ "status": "OK" }
-
Example Failure Value:
{ "detail": "Not found." }
-
Parameters
Parameter Description Parameter Type Data Type Password New password for the user Body String Token Token received by email by the user allowing them to choose a new password Body String -
Response Messages
- 200: OK.
- 400: Bad request.
- 404: Not found.
GET 'api/users/<username>/'
-
Author: Ege Can Kaya
-
Definition: Views the profile of a user
-
Example Response Value:
{ "first_name": "Ege", "last_name": "Kaya", "bio": "Hello, I love sports.", "fav_sport_1": "football", "fav_sport_2": "basketball", "fav_sport_3": "tennis", "location": "Istanbul" }
-
Example Failure Value:
{ "detail": "Not found." }
-
Parameters
Parameter Description Parameter Type Data Type username Username of profile to view Path String -
Response Messages
- 200: OK.
- 404: Not Found
PUT 'api/users/<username>/'
-
Author: Ege Can Kaya
-
Definition: Allows a user to edit their profile
-
Example Response Value:
{ "first_name": "Lewis", "last_name": "Hamilton", "bio": "7-time world champion", "fav_sport_1": "Formula 1", "fav_sport_2": "Formula 2", "fav_sport_3": "Formula E", "location": "Monaco", "avatar": "https://upload.wikimedia.org/wikipedia/commons/1/18/Lewis_Hamilton_2016_Malaysia_2.jpg", "privacy": false }
-
Example Failure Value:
{ "detail": "Unauthorized." }
-
Parameters
Parameter Description Parameter Type Data Type username Username of profile to edit Path String first_name New value for first name Body String last_name New value for last name Body String bio New value for bio Body String fav_sport_1 New value for favorite sport 1 Body String fav_sport_2 New value for favorite sport 2 Body String fav_sport_3 New value for favorite sport 3 Body String location New value for location Body String avatar New value for avatar Body String privacy New value for privacy Body Boolean -
Response Messages
- 200: OK.
- 401: Unauthorized
GET 'api/users/?query=<query>'
-
Author: Ege Can Kaya
-
Definition: Searches profiles by username according to given query
-
Example Response Value:
[ { "id": 1, "username": "egecky", "avatar": "", "privacy": false }, { "id": 2, "username": "dude", "avatar": "", "privacy": true } ]
-
Parameters
Parameter Description Parameter Type Data Type query Query string by which usernames will be searched Query String -
Response Messages
- 200: OK.