This documentation provides information about the API endpoints available in the Edumi backend. Below are the details of each endpoint.
All endpoints are relative to the base URL: http://localhost:4000 (for local development)
- Endpoint: /register
- Method: POST
- Request Body:
- name (string): User's name
- email (string): User's email
- password (string): User's password
- Responses:
- 200: User registered successfully
- 400: Please enter all fields
- 409: User already exists
- Endpoint: /login
- Method: POST
- Request Body:
- email (string): User's email
- password (string): User's password
- Responses:
- 200: Welcome back [user's name]
- 400: Please enter all fields
- 401: Incorrect password or email
- Endpoint: /logout
- Method: POST
- Responses:
- 200: Logged out successfully
- Endpoint: /me
- Method: GET
- Responses:
- 200: User profile details
- Endpoint: /changepassword
- Method: PUT
- Request Body:
- oldPassword (string): User's current password
- newPassword (string): User's new password
- Responses:
- 200: Password changed successfully
- 400: Please enter all fields or Incorrect Password
- Endpoint: /updateprofile
- Method: PUT
- Request Body:
- name (string): Updated user name
- email (string): Updated User's email
- Responses:
- 200: Profile updated successfully
- Endpoint: /forgetpassword
- Method: POST
- Request Body:
- email (string): User's email
- Responses:
- 200: Reset token sent to email successfully
- 404: User not found
- Endpoint: /resetpassword/:token
- Method: PUT
- Request Parameters:
- token (string): Reset token received via email
- Request Body:
- password (string): New password
- Responses:
- 200: Password changed successfully
- 400: Token is invalid or expired
- Endpoint: /addtoplaylist
- Method: POST
- Request Body:
- id (string): Course ID to be added to the playlist
- Responses:
- 200: Added to Playlist
- 400: Invalid course ID
- 400: Course already in playlist
- Endpoint: /removefromplaylist
- Method: DELETE
- Request Query:
- id (string): Course ID to be removed from the playlist
- Responses:
- 200: Removed from Playlist
- 400: Invalid course ID
- Endpoint: /me
- Method: DELETE
- Responses:
- 200: Profile deleted successfully
- Endpoint: /admin/users/:id
- Method: DELETE
- Request Parameters:
- id (string): User ID to be deleted
- Responses:
- 200: Profile deleted successfully
- 200: You are not admin
- Endpoint: /admin/users
- Method: GET
- Responses:
- 200: List of users
- 404: User not found
- 200: You are not admin
- Endpoint: /admin/users/:id
- Method: PUT
- Request Parameters:
- id (string): User ID whose role needs to be updated
- Responses:
- 200: User role updated
- 400: User not found
- 400: User is already an admin
- 400: Error updating user role
- Endpoint: /courses
- Method: GET
- Responses:
- 200: List of all courses
- Endpoint: /createcourse
- Method: POST
- Authentication: Admin Only
- Request Body:
- title (string): Course title
- description (string): Course description
- category (string): Course category
- createdBy (string): Creator of the course
- Responses:
- 201: Course created successfully. You can add lectures later
- Endpoint: /course/:id
- Method: POST
- Authentication : Admin Only
- Request Parameters:
- id (string): Course ID
- Request Body:
- title (string): Lecture title
- description (string): Lecture description
- Responses:
- 200: Lecture added to the course successfully
- 400: Lecture already exists in the course
- 404: Course not found
- Endpoint: /course/:id
- Method: GET
- Request Parameters:
- id (string): Course ID
- Responses:
- 200: Course details with lectures
- 404: Course not found
- Endpoint: /course/sortCourses
- Method: GET
- Request Parameters:
- /sort?sortBy=popularity.
- Responses:
- 200: Courses according to the sort criteria
- Endpoint: /course/searchCourses
- Method: GET
- Request Parameters:
- /searchCourses?keyword=
- Responses:
- 200: Courses according to the search