-
Notifications
You must be signed in to change notification settings - Fork 2
API Doc
This API documentation provides detailed information for our endpoint. Each section outlines the HTTP method, endpoint, a description of the operation, and the required request body. It also includes example curl commands to demonstrate how to interact with the API (or just use Postman).
-
Endpoint:
POST /register - Description: Registers a new user (select a role between Student and Educator)
-
Request Body:
{ "username": "dev", "email": "[email protected]", "password": "MyPasssword123", "confirm_password": "MyPasssword123", "role": "student" } -
Example:
curl -X POST http://localhost:4000/register -H "Content-Type: application/json" -d '{ "username": "dev", "email": "[email protected]", "password": "MyPasssword123", "confirm_password": "MyPasssword123", "role": "student" }'
-
Endpoint:
POST /login - Description: Logs in an existing user.
-
Request Body:
{ "email": "[email protected]", "password": "MyPasssword123" } -
Example:
curl -X POST http://localhost:4000/login -H "Content-Type: application/json" -d '{ "email": "[email protected]", "password": "MyPasssword123" }'
-
Endpoint:
DELETE /delete -
Description: Deletes a user by
user_id. -
Request Body:
{ "password": "Password1234", "user_id": "1" } -
Example:
curl -X DELETE http://localhost:4000/delete -H "Content-Type: application/json" -d '{ "password": "Password1234", "user_id": "1" }'
-
Endpoint:
GET /user/:user_id -
Description: Get user by
user_id. -
Example:
curl -X GET http://localhost:4000/user/10
-
Endpoint:
PUT /update-username -
Description: Updates the username of a user.
-
Request Body:
{ "user_id": "1", "token": "your_token_here", "username": "newUsername" } -
Example:
curl -X PUT http://localhost:4000/update-username -H "Content-Type: application/json" -d '{ "user_id": "1", "token": "your_token_here", "username": "newUsername" }'
-
Endpoint:
PUT /update-email -
Description: Updates the email address of a user. For validation, the
confirm_emailfield must match theemailfield. -
Request Body:
{ "user_id": "1", "token": "your_token_here", "email": "[email protected]", "confirm_email": "[email protected]" } -
Example:
curl -X PUT http://localhost:4000/update-email -H "Content-Type: application/json" -d '{ "user_id": "1", "token": "your_token_here", "email": "[email protected]", "confirm_email": "[email protected]" }'
-
Endpoint:
PUT /update-password -
Description: Updates the user's password and logs the user out by revoking the current token. The
confirm_passwordfield must match thepasswordfield, and a validtokenis required for authentication. -
Request Body:
{ "user_id": "1", "token": "your_token_here", "password": "NewPassword123", "confirm_password": "NewPassword123" } -
Example:
curl -X PUT http://localhost:4000/update-password -H "Content-Type: application/json" -d '{ "user_id": "1", "token": "your_token_here", "password": "NewPassword123", "confirm_password": "NewPassword123" }'