-
Notifications
You must be signed in to change notification settings - Fork 5
API Endpoints
Attempt to create an account, if successful send email confirmation. Will check if email is in use, will not validate for matching passwords or email formatting.
Requires session cookie.
POST /users
| Parameter | Type | Description | Requirement Type |
|---|---|---|---|
| string | Email address of the user. | Required | |
| password | string | Password of the user. | Required |
| confirmedPassword | string | Password of the user for validation. | Required |
| firstName | string | User's first name. | Required |
| lastName | string | User's last name. | Required |
fetch(`http://localhost:3001/users`, {
method: 'POST',
body: new URLSearchParams({
'email': 'jdoe@example.com',
'password': 'YourSecurePassword',
'confirmedPassword': 'YourSecurePassword',
'firstName': 'John',
'lastName': 'Doe'
})
}).then(response => response.json())
.then(data => ...);
| Parameter | Type | Description |
|---|---|---|
| token | string | The user token generated upon successful account creation. (Only for successful requests) |
| error | string | Error message detailing why the request failed. (Only for failed requests) |
| Status Code | Description |
|---|---|
| 201 | Account created successfully. |
| 400 | Bad request, required information missing or invalid. |
| 500 | Internal server error. |
{
'token': '6d167d57abd239ff77f67fd402d510b1f3b1286b10d03e7c48b30e200f529a8e'
}
Request password reset by sending an OTP reset code to the user's email if the email is attached to an account.
None required, but utilizes user's email for identification.
PUT /users/password?email={email}
N/A - URL Query Parameters used.
fetch(`http://localhost:3001/users/password?email=jdoe@example.com`, {
method: 'PUT'
}).then(response => response.json())
.then(data => ...);
N/A
| Status Code | Description |
|---|---|
| 200 | Email sent or account not found (for privacy). |
| 500 | Server error. |
{
// Response is indicated through HTTP status code
}
Authenticate the user with credentials provided or use the token to authenticate.
Optional initial authentication via email and password, or via session token.
POST /users/authenticate
| Parameter | Type | Description | Requirement Type |
|---|---|---|---|
| string | Email address of the user | Optional | |
| password | string | Password of the user | Optional |
fetch(`http://localhost:3001/users/authenticate`, {
method: 'POST',
body: JSON.stringify({
'email': 'jdoe@example.com',
'password': 'YourSecurePassword'
}),
headers: {
'Content-Type': 'application/json'
}
}).then(response => response.json())
.then(data => ...);
| Parameter | Type | Description |
|---|---|---|
| token | string | The user token generated upon successful authentication. |
| Status Code | Description |
|---|---|
| 200 | Authentication successful. |
| 401 | Unauthenticated, wrong credentials provided. |
| 500 | Internal server error. |
{
'token': '6d167d57abd239ff77f67fd402d510b1f3b1286b10d03e7c48b30e200f529a8e'
}
Retrieve user information by user ID after authenticating token.
Requires valid user token.
GET /users/:user_id
N/A - URL Parameters used.
fetch(`http://localhost:3001/users/12345`, {
method: 'GET',
headers: {
'Authorization': 'Bearer 6d167d57abd239ff77f67fd402d510b1f3b1286b10d03e7c48b30e200f529a8e'
}
}).then(response => response.json())
.then(data => ...);
| Parameter | Type | Description |
|---|---|---|
| string | Email address of the user. | |
| firstName | string | First name of the user. |
| lastName | string | Last name of the user. |
| Status Code | Description |
|---|---|
| 200 | User information successfully retrieved. |
| 404 | User not found. |
| 401 | Unauthorized access attempt. |
{
'email': 'jdoe@example.com',
'firstName': 'John',
'lastName': 'Doe'
}
Edit account information after authenticating with the old password or password reset token.
Requires valid user token and either old password validation or password reset token.
PUT /users/:user_id
| Parameter | Type | Description | Requirement Type |
|---|---|---|---|
| string | New email address of the user. | Optional | |
| oldPassword | string | Old password of the user. | Optional |
| newPassword | string | New password of the user. | Optional |
| confirmedPassword | string | New password of the user for validation. | Optional |
| firstName | string | New first name of the user. | Optional |
| lastName | string | New last name of the user. | Optional |
| emailConfirmation | string | Confirmation code sent to the new email. | Optional |
fetch(`http://localhost:3001/users/12345`, {
method: 'PUT',
body: JSON.stringify({
'email': 'newjdoe@example.com',
'oldPassword': 'YourSecurePassword',
'newPassword': 'YourNewSecurePassword',
'confirmedPassword': 'YourNewSecurePassword',
'firstName': 'Johnathan',
'lastName': 'Doe'
}),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer 6d167d57abd239ff77f67fd402d510b1f3b1286b10d03e7c48b30e200f529a8e'
}
}).then(response => response.json())
.then(data => ...);
| Parameter | Type | Description |
|---|---|---|
| string | Updated email address of the user. | |
| firstName | string | Updated first name of the user. |
| lastName | string | Updated last name of the user. |
| Status Code | Description |
|---|---|
| 200 | User information updated successfully. |
| 400 | Bad request, validation errors. |
| 401 | Unauthorized, wrong old password or token. |
| 500 | Internal server error. |
{
'email': 'newjdoe@example.com',
'firstName': 'Johnathan',
'lastName': 'Doe'
}
Delete a user account and associated data after authenticating token.
Requires valid user token.
DELETE /users/:user_id
N/A - URL Parameters used.
fetch(`http://localhost:3001/users/12345`, {
method: 'DELETE',
headers: {
'Authorization': 'Bearer 6d167d57abd239ff77f67fd402d510b1f3b1286b10d03e7c48b30e200f529a8e'
}
}).then(response => response.json())
.then(data => ...);
N/A
| Status Code | Description |
|---|---|
| 200 | Account successfully deleted. |
| 404 | Account not found or not authorized to delete. |
| 500 | Server error. |
{
// Response is indicated through HTTP status code
}
List all courses a user is enrolled in, with differences between teacher and student roles.
Requires valid user token.
- Description: Confirm the user's email address
-
Request:
- Params:
userId: "string" - Body:
{ "emailConfirmationCode": "string" }
- Params:
-
Response:
- Success:
200 OK - Error:
400 Bad Request,401 Unauthorized,403 Forbidden,404 Not Found,409 Conflict,498 Invalid Token
- Success:
- Description: Request a new email confirmation code
-
Request:
- Params:
userId: "string"
- Params:
-
Response:
- Success:
200 OK - Error:
400 Bad Request,403 Forbidden,404 Not Found
- Success:
GET /courses
N/A
fetch(`http://localhost:3001/courses`, {
method: 'GET',
headers: {
'Authorization': 'Bearer 6d167d57abd239ff77f67fd402d510b1f3b1286b10d03e7c48b30e200f529a8e'
}
}).then(response => response.json())
.then(data => ...);
| Parameter | Type | Description |
|---|---|---|
| courses | Array | List of courses the user is enrolled in, with role-specific data. |
| Status Code | Description |
|---|---|
| 200 | Successfully retrieved list of courses. |
| 401 | Unauthorized, token invalid. |
| 500 | Internal server error. |
{
'courses': [...]
}
Create a course and enroll the creator as a teacher.
Requires valid user token.
POST /courses
| Parameter | Type | Description | Requirement Type |
|---|---|---|---|
| name | string | Name of the course. | Required |
| description | string | Description of the course. | Required |
fetch(`http://localhost:3001/courses`, {
method: 'POST',
body: JSON.stringify({
'name': 'Advanced Mathematics',
'description': 'A course on advanced mathematics topics.'
}),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer 6d167d57abd239ff77f67fd402d510b1f3b1286b10d03e7c48b30e200f529a8e'
}
}).then(response => response.json())
.then(data => ...);
| Parameter | Type | Description |
|---|---|---|
| id | string | ID of the newly created course. |
| name | string | Name of the newly created course. |
| description | string | Description of the newly created course. |
| Status Code | Description |
|---|---|
| 201 | Course created successfully. |
| 400 | Bad request, required information missing or invalid. |
| 401 | Unauthorized, token invalid. |
| 500 | Internal server error. |
{
'id': 'course123',
'name': 'Advanced Mathematics',
'description': 'A course on advanced mathematics topics.'
}
Enroll a user in a course section using a join code.
Requires valid user token.
POST /courses/join
| Parameter | Type | Description | Requirement Type |
|---|---|---|---|
| joinCode | string | Join code for the course section. | Required |
fetch(`http://localhost:3001/courses/join`, {
method: 'POST',
body: JSON.stringify({
'joinCode': 'ABC123'
}),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer 6d167d57abd239ff77f67fd402d510b1f3b1286b10d03e7c48b30e200f529a8e'
}
}).then(response => response.json())
.then(data => ...);
| Parameter | Type | Description |
|---|---|---|
| section | string | The section the user was enrolled |
| Status Code | Description |
|---|---|
| 200 | Successfully joined the course. |
| 400 | Bad request, join code invalid. |
| 401 | Unauthorized, token invalid. |
| 404 | Course or section not found. |
| 500 | Internal server error. |
- Description: Update a course's information
-
Request:
- Params:
course_id: "string" - Body:
{ "name": "string", "description": "string", "published": "boolean", ... }
- Params:
-
Response:
- Success:
200 OK,{ course: { ... } } - Error:
400 Bad Request,403 Forbidden,{ error: "message" }
- Success:
- Description: Delete a course
-
Request:
- Params:
course_id: "string"
- Params:
-
Response:
- Success:
204 No Content - Error:
403 Forbidden,{ error: "message" }
- Success:
-
Description: Additional endpoints related to courses
/courses/:course_id/lectures/courses/:course_id/enrollments/courses/:course_id/questions/courses/:course_id/sections/courses/:course_id/sections/:section_id/lectures/:lecture_id/responses/courses/:course_id/sections/:section_id/grades
- Description: Get the roster for a course
- Request: None
-
Response:
- Success:
200 OK,{ enrollments: [...] } - Error:
403 Forbidden,{ error: "Only the teacher for a course can view the roster" }
- Success:
- Description: Delete a student from a course roster
-
Request:
- Params:
course_id: "string",enrollment_id: "string"
- Params:
-
Response:
- Success:
204 No Content - Error:
403 Forbidden,400 Bad Request,{ error: "message" }
- Success:
- Description: Change a student's section
-
Request:
- Params:
course_id: "string",enrollment_id: "string" - Body:
{ "sectionId": "string" }
- Params:
-
Response:
- Success:
200 OK,{ enrollment: { ... } } - Error:
403 Forbidden,400 Bad Request,{ error: "message" }
- Success:
- Description: Get the list of courses for the authenticated user
- Request: None
-
Response:
- Success:
200 OK,{ studentCourses: [...], teacherCourses: [...] }
- Success:
- Description: Create a new course
-
Request:
- Body:
{ "name": "string", ... }
- Body:
-
Response:
- Success:
201 Created,{ course: { ... }, enrollment: { ... } } - Error:
400 Bad Request,{ error: "message" }
- Success:
- Description: Join a course using a join code
-
Request:
- Body:
{ "joinCode": "string" }
- Body:
-
Response:
- Success:
201 Created,{ section: { ... }, course: { ... }, enrollment: { ... } } - Error:
400 Bad Request,404 Not Found,{ error: "message" }
- Success:
- Description: Update a course's information
-
Request:
- Params:
course_id: "string" - Body:
{ "name": "string", "description": "string", "published": "boolean", ... }
- Params:
-
Response:
- Success:
200 OK,{ course: { ... } } - Error:
400 Bad Request,403 Forbidden,{ error: "message" }
- Success:
- Description: Delete a course
-
Request:
- Params:
course_id: "string"
- Params:
-
Response:
- Success:
204 No Content - Error:
403 Forbidden,{ error: "message" }
- Success:
-
Description: Additional endpoints related to courses
/courses/:course_id/lectures/courses/:course_id/enrollments/courses/:course_id/questions/courses/:course_id/sections/courses/:course_id/sections/:section_id/lectures/:lecture_id/responses/courses/:course_id/sections/:section_id/grades
- Description: Get the roster for a course
- Request: None
-
Response:
- Success:
200 OK,{ enrollments: [...] } - Error:
403 Forbidden,{ error: "Only the teacher for a course can view the roster" }
- Success:
- Description: Delete a student from a course roster
-
Request:
- Params:
course_id: "string",enrollment_id: "string"
- Params:
-
Response:
- Success:
204 No Content - Error:
403 Forbidden,400 Bad Request,{ error: "message" }
- Success:
- Description: Change a student's section
-
Request:
- Params:
course_id: "string",enrollment_id: "string" - Body:
{ "sectionId": "string" }
- Params:
-
Response:
- Success:
200 OK,{ enrollment: { ... } } - Error:
403 Forbidden,400 Bad Request,{ error: "message" }
- Success:
Base path: /courses/:course_id/sections/:section_id/lectures
- Description: Get the currently live lecture for a student in a section if one exists.
-
Request:
- Params:
-
course_id:number -
section_id:number(used as user ID)
-
- Params:
-
Response:
- Success:
200 OK{ "filteredLecture": { "name": "string", "id": "number", "isLive": true, "closedAt": "datetime" } } - Errors:
-
403 Forbidden– Not enrolled -
404 Not Found– No live lecture found
-
- Success:
- Description: Get all lectures in a section (Teacher only).
-
Request:
- Params:
-
course_id:number -
section_id:number
-
- Params:
-
Response:
- Success:
200 OK{ "lectures": [ { "id": "number", "title": "string", "attendanceMethod": "string", "published": true, "isLive": false, ... } ] } - Errors:
-
403 Forbidden– Not a teacher -
404 Not Found– Section not found
-
- Success:
- Description: Add a lecture to a section.
-
Request:
- Params:
-
course_id:number -
section_id:number
-
- Body:
{ "lectureId": "number", "attendanceMethod": "string", "weight": "number" }
- Params:
-
Response:
- Success:
200 OK{ "id": "number", "sectionId": "number", "lectureId": "number", "attendanceMethod": "string", "published": false } - Errors:
-
400 Bad Request– Missing or duplicate lecture -
403 Forbidden– Not a teacher -
404 Not Found– Section or lecture not found
-
- Success:
- Description: Toggle publish status of a lecture in a section (Teacher only).
-
Request:
- Params:
-
course_id:number -
section_id:number -
lecture_id:number
-
- Params:
-
Response:
- Success:
200 OK - Errors:
-
400 Bad Request– Invalid relationships -
403 Forbidden– Not a teacher -
404 Not Found– Section not found
-
- Success:
- Description: Delete a lecture from a section (Teacher only).
-
Request:
- Params:
-
course_id:number -
section_id:number -
lecture_id:number
-
- Params:
-
Response:
- Success:
200 OK{ "message": "LectureForSection deleted successfully" } - Errors:
-
403 Forbidden– Not a teacher -
404 Not Found– Section or lecture not found
-
- Success:
- Description: Get all questions for a lecture in a section (Teacher only).
-
Request:
- Params:
-
course_id:number -
section_id:number -
lecture_id:number
-
- Params:
-
Response:
- Success:
200 OK{ "questions": [ { "id": "number", "text": "string", "type": "string", ... } ] } - Errors:
-
403 Forbidden– Not a teacher -
404 Not Found– Section, lecture, or lectureForSection not found
-
- Success:
-
Description: Update the
isLivestatus of a lecture in a section. -
Request:
- Params:
-
course_id:number -
section_id:number -
lecture_id:number -
live_status:boolean(e.g.,trueorfalse)
-
- Params:
-
Response:
- Success:
200 OK - Errors:
-
400 Bad Request– Invalid data or relationship -
403 Forbidden– Not a teacher -
404 Not Found– Section or lecture not found
-
- Success:
- All routes require authentication.
- Teachers can only modify data for courses they teach.
- Students can access live lecture info if enrolled.
- Description: Add a new section to a course
-
Request:
- Params:
course_id: "string" - Body:
{ "number": "string" }
- Params:
-
Response:
- Success:
201 Created,{ section: { ... } } - Error:
400 Bad Request,{ error: "message" }
- Success:
- Description: Get all sections within a course
- Request: None
-
Response:
- Success:
200 OK,[ { ... } ] - Error:
403 Forbidden,{ error: "message" }
- Success:
- Description: Get a specific section and lectures for that section
-
Request:
- Params:
course_id: "string",section_id: "string"
- Params:
-
Response:
- Success:
200 OK,{ section: { ... }, lectures: [...] } - Error:
403 Forbidden,404 Not Found,{ error: "message" }
- Success:
- Description: Update a specific section
-
Request:
- Params:
course_id: "string",section_id: "string" - Body:
{ "number": "string" }
- Params:
-
Response:
- Success:
200 OK - Error:
400 Bad Request,403 Forbidden,{ error: "message" }
- Success:
-
Description: Additional endpoints related to sections
/courses/:course_id/sections/:section_id/lectures
-
Description: Submit a new response to a question within a lecture. Only students enrolled in the course can respond. The submission must contain at least two selected answers. The score is computed using a weighted scheme based on correct and incorrect selections.
-
Request:
- Params:
-
course_id:string -
lecture_id:string -
question_id:string
-
- Body:
{ "answers": { "0": true, "1": false, ... } } - Query (optional):
-
points:number(Overrides computed correct points) -
totalPoints:number(Overrides computed total possible points)
-
- Params:
-
Response:
- Success:
201 Created{ "response": { "id": "string", "submission": { ... }, "score": "number", "points": "number", "totalPoints": "number", ... } } - Errors:
-
400 Bad Request– Invalid parameters or insufficient answer options -
403 Forbidden– User is not a student in the course -
404 Not Found– Section, lecture, or question not found
-
- Success:
-
Description: Resubmit or update a response to a question in a lecture. Only the original student who submitted the response can update it. The question must be published and valid. At least two options must be submitted.
-
Request:
- Params:
-
course_id:string -
lecture_id:string -
question_id:string -
response_id:string
-
- Body:
{ "answers": { "0": true, "1": false, ... } } - Query (optional):
-
points:number(Overrides computed correct points) -
totalPoints:number(Overrides computed total possible points)
-
- Params:
-
Response:
- Success:
200 OK{ "response": { "id": "string", "submission": { ... }, "score": "number", ... } } - Errors:
-
400 Bad Request– Invalid request parameters or insufficient answers -
403 Forbidden– Not authorized to edit the response -
404 Not Found– Response, question, or lecture not found
-
- Success:
- Description: Get all questions for a given course
-
Request:
- Params:
course_id: "string" - Query:
search="string"&page="number"&perPage="number"
- Params:
-
Response:
- Success:
200 OK,{ questions: [...], links: { nextPage: "url", prevPage: "url" } } - Error:
403 Forbidden,{ error: "message" }
- Success:
- Description: Create a new question for a given course
-
Request:
- Params:
course_id: "string" - Body:
{ ... }
- Params:
-
Response:
- Success:
201 Created,{ question: { ... } } - Error:
400 Bad Request,{ error: "message" }
- Success:
- Description: Get the responses to questions given in a lecture
-
Request:
- Params:
course_id: "string",section_id: "string",lecture_id: "string"
- Params:
-
Response:
- Success:
200 OK,[ { ... } ] - Error:
403 Forbidden,{ error: "message" }
- Success:
- Description: (Un)publish a lecture in a section
-
Request:
- Params:
course_id: "string",section_id: "string",lecture_id: "string"
- Params:
-
Response:
- Success:
200 OK - Error:
403 Forbidden,{ error: "message" },404 Not Found
- Success:
- Description: Get a question inside a lecture
-
Request:
- Params:
course_id: "string",lecture_id: "string",question_id: "string"
- Params:
-
Response:
- Success:
200 OK,{ ...questionFields, ...questionInLectureFields } - Error:
400 Bad Request,403 Forbidden,404 Not Found,{ error: "message" }
- Success:
- Description: (Un)publish a question inside a lecture
-
Request:
- Params:
course_id: "string",lecture_id: "string",question_id: "string"
- Params:
-
Response:
- Success:
200 OK - Error:
400 Bad Request,403 Forbidden,404 Not Found,{ error: "message" }
- Success:
- Description: Connect a question to a lecture
-
Request:
- Params:
course_id: "string",lecture_id: "string",question_id: "string" - Body:
{ "order": "number", "published": "boolean" }
- Params:
-
Response:
- Success:
201 Created,{ ...newQuestionInLectureFields } - Error:
400 Bad Request,403 Forbidden,{ error: "message" }
- Success:
- Description: Swap the order of two questions in a lecture
-
Request:
- Params:
course_id: "string",lecture_id: "string" - Body:
{ "questionIdOne": "string", "questionIdTwo": "string" }
- Params:
-
Response:
- Success:
200 OK - Error:
400 Bad Request,403 Forbidden,{ error: "message" }
- Success:
- Description: Remove a question from a lecture
-
Request:
- Params:
course_id: "string",lecture_id: "string",question_id: "string"
- Params:
-
Response:
- Success:
204 No Content - Error:
400 Bad Request,403 Forbidden,404 Not Found,{ error: "message" }
- Success:
-
Description: Additional endpoints related to questions in lecture
/courses/:course_id/lectures/:lecture_id/questions/:question_id/responses
-
Description:
- If the requester is a teacher, returns a list of all students in the course along with their overall course grades.
- If the requester is a student, returns only their own course grade.
-
Request:
- Params:
-
course_id: string— The ID of the course.
-
- Params:
-
Response:
-
Success:
200 OK- Teacher:
[{ studentId, studentName, grade }] - Student:
{ studentId, studentName, grade }
- Teacher:
-
Error:
-
403 Forbidden:{ error: "message" }
-
-
Success:
-
Description:
- Returns all students’ grades for a specific section of a course. Accessible by teachers only.
-
Request:
- Params:
-
course_id: string— The ID of the course. -
section_id: string— The ID of the section.
-
- Params:
-
Response:
-
Success:
200 OK[{ studentId, studentName, grade }]
-
Error:
-
403 Forbidden:{ error: "message" }
-
-
Success:
-
Description:
- Returns grade details for a specific student in a specific section. Accessible by teachers or the student themselves.
-
Request:
- Params:
-
course_id: string— The ID of the course. -
section_id: string— The ID of the section. -
student_id: string— The ID of the student.
-
- Params:
-
Response:
-
Success:
200 OK{ studentId, studentName, grade }
-
Error:
-
403 Forbidden:{ error: "message" } -
404 Not Found:{ error: "message" }
-
-
Success: