-
Notifications
You must be signed in to change notification settings - Fork 2
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': '[email protected]',
'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/[email protected]`, {
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': '[email protected]',
'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': '[email protected]',
'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': '[email protected]',
'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': '[email protected]',
'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:
- 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 response to a question in a lecture
-
Request:
- Params:
course_id: "string"
,lecture_id: "string"
,question_id: "string"
- Body:
{ "answers": { ... } }
- Params:
-
Response:
- Success:
201 Created
,{ response: { ... } }
- Error:
400 Bad Request
,403 Forbidden
,{ error: "message" }
- Success:
- Description: Resubmit a response to a question in a lecture
-
Request:
- Params:
course_id: "string"
,lecture_id: "string"
,question_id: "string"
,response_id: "string"
- Body:
{ "answers": { ... } }
- Params:
-
Response:
- Success:
200 OK
,{ response: { ... } }
- Error:
400 Bad Request
,403 Forbidden
,{ error: "message" }
- 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: Get grades for each student in the course (teacher) or get their own grade for the course (student)
-
Request:
- Params:
course_id: "string"
- Params:
-
Response:
- Success:
200 OK
,[...]
- Error:
403 Forbidden
,{ error: "message" }
- Success:
- Description: Get all grades for a section
-
Request:
- Params:
course_id: "string"
,section_id: "string"
- Params:
-
Response:
- Success:
200 OK
,[{ studentId, studentName, grade }]
- Error:
403 Forbidden
,{ error: "message" }
- Success:
- Description: Get grades for a specific student in a section
-
Request:
- Params:
course_id: "string"
,section_id: "string"
,student_id: "string"
- Params:
-
Response:
- Success:
200 OK
,{ studentId, studentName, grade }
- Error:
403 Forbidden
,404 Not Found
,{ error: "message" }
- Success: