Login
Login
Route: POST /login
Description: Login a user.
Request Body: JSON containing username and
password.
Response: JSON object containing token.
Need to include the token in the header of all future requests.
Subjects
Get All Subjects
Route: GET /subjects
Description: Retrieve a list of all subjects.
Response: JSON array of subjects with id,
name, average, points,
num_exams, weight for each subject.
Requires: x-access-token header.
Get a Single Subject
Route: GET /subjects/{subjectId}
Description: Retrieve details for a specific subject by its ID.
Response: JSON object containing id,
name, average, points,
num_exams, weight for the specified subject.
Requires: x-access-token header.
Create a New Subject
Route: POST /subjects
Description: Add a new subject.
Request Body: JSON containing name and
optionally weight (defaults to 1).
Response: JSON object of the created subject.
Requires: x-access-token header.
Update a Subject
Route: PUT /subjects/{subjectId}
Description: Update details of an existing subject.
Request Body: JSON containing name
and/or weight. The weight field affects how
much the subject's average contributes to the total average (default: 1).
Response: JSON object indicating success/failure.
Requires: x-access-token header.
Delete a Subject
Route: DELETE /subjects/{subjectId}
Description: Remove a subject by its ID.
Response: JSON object indicating success/failure.
Requires: x-access-token header.
Grades
Get All Grades
Route: GET /grades
Description: Retrieve a list of all grades.
Response: JSON array with id,
grade, weight, date,
details, subject
Requires: x-access-token header.
Get Grades for a Specific Subject
Route:
GET /subjects/{subjectId}/grades
Description: Retrieve all grades for a specific subject.
Response: JSON array of id,
grade, weight, date,
details for each grade of the specified subject.
Requires: x-access-token header.
Get a Single Grade
Route: GET /grades/{gradeId}
Description: Retrieve details of a specific grade by its ID.
Response: JSON object containing id,
grade, weight, date,
details, subject
Requires: x-access-token header.
Create a New Grade
Route: POST /grades
Description: Add a new grade.
Request Body: JSON containing date,
name, grade, details,
weight and subject_id or
subject_name. It will even create a new subject if it
doesn't exist and return the new subject's ID.
Response: JSON object of the created grade.
Requires: x-access-token header.
Update a Grade
Route: PUT /grades/{gradeId}
Description: Update details of an existing grade.
Request Body: JSON containing date,
name, grade, detailsand/or
weight.
Response: JSON object of the updated grade.
Requires: x-access-token header.
Delete a Grade
Route: DELETE /grades/{gradeId}
Description: Remove a grade by its ID.
Response: JSON object indicating success/failure.
Requires: x-access-token header.
Users
Get User
Route: GET /user
Description: Retrieve details of the current user.
Response: JSON object containing id,
username, total_average,
total_points, total_exams.
Requires: x-access-token header.
Update User Password
Route: PUT /user/update_password
Description: Update the password of the current user.
Request Body: JSON containing
old_password, new_password.
Response: JSON object indicating success/failure.
Requires: x-access-token header.
Update Username
Route: PUT /user/update_username
Description: Update the username of the current user.
Request Body: JSON containing username and
password.
Response: JSON object indicating success/failure.
Requires: x-access-token header.
Register
Route: POST or PUT /register
Description: Register a new user.
Request Body: JSON containing username,
password.
Response: JSON object of the created user.
Delete User
Route: DELETE /user
Description: Delete the current user.
Response: JSON object indicating success/failure.
Requires: x-access-token header.