All the endpoints below are protected by authenticating the user's session cookies before allowing requests or redirects to happen.
Authentication happens at separate endpoints (see section on Authentication endpoints).
In your requests, make sure to include credentials with the credentials: 'include' parameter so these are passed on appropriately:
const response = await fetch(backend/protected, {
method: 'GET',
credentials: 'include',
});- Endpoint:
/api/v1/searchuser/:method/:query- NOTE: Replace
:methodwith the search method and:querywith the search query.
- NOTE: Replace
- Description: Returns a list of users that have similar usernames to the query provided
- Request Method: GET
- Parameters:
method(string): Method to search users by, must be either"name"(by username) orcode(by social code)query(string): Query to match usernames to
- Response:
- Status Code: 200 OK
- Body: JSON
{ "num_results": 2, "users": [ { "BossId": 0, "Picture": "", "Points": 0, "SoicalCode": "1", "Username": "person1" }, { "BossId": 0, "Picture": "", "Points": 0, "SoicalCode": "2", "Username": "person2" }, ] }
- Endpoint:
/api/v1/addFreind/:code- NOTE: Replace
:codewith the wanted friend's code.
- NOTE: Replace
- Description: Adds the other user as a friend
- Request Method: POST
- Parameters:
code(string): The friend's social code
- Response:
- Status Code: 200 OK
- Body: JSON
{ "message": "Success" }
- Endpoint:
/api/v1/removeFriend/:code- NOTE: Replace
:codewith the wanted friend's code.
- NOTE: Replace
- Description: Removes the other user as a friend (no side effects if not already friends)
- Request Method: DELETE
- Parameters:
code(string): The friend's social code
- Response:
- Status Code: 200 OK
- Body: JSON
{ "message": "Success" }
- Endpoint:
/api/v1/user/friends - Description: Gets the friend list of the current logged in user.
- Request Method: GET
- Response:
- Status Code: 200 OK
- Body: JSON
{ "list": [ { "BossId": 0, "Picture": "", "Points": 0, "SoicalCode": "AYYLMAO1", "Username": "sluggo1" }, { "BossId": 0, "Picture": "", "Points": 0, "SoicalCode": "LOLLLL2", "Username": "sluggo2" }, "num_friends": 2 ] }
- Endpoint:
/api/v1/tasks - Description: Get all tasks for the current logged in user.
- Request Method: GET
- Response:
- Status Code: 200 OK
- Body: JSON Sample Response
{ "task": { "TaskID": 1, "UserID": "testUserId", "Category": "yo", "TaskName": "New Task", "Description": "Description of the new task", "StartTime": "2024-01-01T08:00:00Z", "EndTime": "2024-01-01T17:00:00Z", "Status": "completed", "IsRecurring": false, "IsAllDay": false, "Difficulty": "easy", "CronExpression": "" } }
- Endpoint:
/api/v1/task/:id- NOTE: Replace
:idwith the actual TaskID.
- NOTE: Replace
- Description: Get a task by ID.
- Request Method: GET
- Parameters:
id(integer): The ID of the task.
- Response:
- Status Code: 200 OK
- Body: JSON
{ "task": { "TaskID": 1, "UserID": "testUserId", "Category": "yo", "TaskName": "New Task", "Description": "Description of the new task", "StartTime": "2024-01-01T08:00:00Z", "EndTime": "2024-01-01T17:00:00Z", "Status": "completed", "IsRecurring": false, "IsAllDay": false, "Difficulty": "easy", "CronExpression": "" } }
- Endpoint:
/api/v1/userTasks/:start/:end- NOTE: Replace
:start, and:endwith the actual start time, and end time respectively. - Ex.:
/api/v1/userTasks/123/2024-02-09T00:00:00Z/2024-02-10T00:00:00Z
- NOTE: Replace
- Description: Get tasks for the user within a specified time range.
- Request Method: GET
- URL Parameters:
startThe start time of the time range.endThe end time of the time range.
- Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "list": [ { "TaskID": 123, "UserID": "user123", "Category": "Party time", "TaskName": "Party", "StartTime": "2024-02-09T08:00:00Z", "EndTime": "2024-02-09T17:00:00Z", "Status": "todo", "IsRecurring": false, "IsAllDay": false }, // ... more task previews ] }
- Endpoint:
/api/v1/userPoints - Description: Retrieve the points associated with the authenticated user.
- Request Method: GET
- Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "points": 42 }
- Endpoint:
/api/v1/user - Description: Get public user information that can be displayed to user
- Request Method: GET
- Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "BossId": 0, "Picture": "images/lol.png", "Points": 42, "SoicalCode": "AYYLMAO1", "Username": "sluggo1" }
- Endpoint:
/api/v1/getBossHealth - Description: Get the current health of the boss associated with the authenticated user.
- Request Method: GET
- Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "curr_boss_health": 30 }
- Endpoint:
/api/v1/getBoss/:id- NOTE: Replace
:idwith the actual BossID. - Ex.:
/api/v1/getBoss/123
- NOTE: Replace
- Description: Get information about a boss by its ID.
- Request Method: GET
- Parameters:
id(integer): The ID of the boss.
- Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "boss": { "BossID": 123, "Name": "Boss Name", "Health": 100, "Image": "http://localhost:8080/api/v1/images/clown.jpg" } }BossID: The unique identifier for the boss.Name: The name of the boss.Health: The current health of the boss.Image: URL of the boss image.
- Endpoint:
/api/v1/makeCat - Description: Create a new category for the authenticated user.
- Request Method: PUT
- Request Headers:
Content-Type: application/json
- Request Body: JSON Sample Request Body
{ "UserID": "user123", "Name": "Personal", "Color": 128 } - Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "message": "Success", "catID": 789 }
- Endpoint:
/api/v1/task/:id- NOTE: Replace
:idwith the actual TaskID.
- NOTE: Replace
- Description: Edit an existing task.
- Request Method: PUT
- URL Parameters:
id(integer): The ID of the task to be edited.
- Body: JSON
{ "TaskID": 1, "UserID": "testUserId", "Category": "yo", "TaskName": "New Task", "Description": "Description of the new task", "StartTime": "2024-01-01T08:00:00Z", "EndTime": "2024-01-01T17:00:00Z", "Status": "completed", "IsRecurring": false, "IsAllDay": false, "Difficulty": "easy", "CronExpression": "" //for now, recurring functions are not supported } - Response:
- Status Code: 200 OK
- Endpoint:
/api/v1/passtask/:idand/api/v1/failtask/:id- NOTE: Replace
:idwith the actual TaskID. - Ex.:
/api/v1/passtask/123or/api/v1/failtask/456
- NOTE: Replace
- Description: Mark a task as completed (pass) or uncompleted (fail).
- Request Method: POST
- URL Parameters:
id(integer): The ID of the task to be marked as completed or uncompleted.
- Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "message": "Success", "bossId": 1 }
Certainly! Below is the documentation for the endpoints related to passing and failing recurring tasks:
- Endpoint:
/api/v1/passRecurringTask/:id/:recurrenceID- NOTE: Replace
:idwith the actual TaskID and:recurrenceIDwith the ID of the particular recurring task. - Ex.:
/api/v1/passRecurringTask/123/111
- NOTE: Replace
- Description: Marks a recurring task as pass.
- Request Method: POST
- URL Parameters:
id(integer): Overall task idrecurrenceID(integer): reucrring task id
- Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "message": "Success", "bossId": 1 }
- Endpoint:
/api/v1/failRecurringTask/:id/:recurrenceID- NOTE: Replace
:idwith the actual TaskID and:recurrenceIDwith the ID of the particular recurring task. - Ex.:
/api/v1/failRecurringTask/123/456
- NOTE: Replace
- Description: Marks a recurring task as failed.
- Request Method: POST
- URL Parameters:
id(integer): TaskIdrecurrenceID(integer): ID of actual recurring task
- Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "message": "Success" }
- Endpoint:
/api/v1/task - Description: Create a new task.
- Request Method: POST
- Body: JSON Sample Request Body
{ "task": { "UserID": "testUserId", "Category": "yo", "TaskName": "New Task", "Description": "Description of the new task", "StartTime": "2024-01-01T08:00:00Z", "EndTime": "2024-01-01T17:00:00Z", "Status": "completed", "IsRecurring": false, "IsAllDay": false, "Difficulty": "easy", "CronExpression": "" //for now, recurring functions are not supported } } "task": { "UserID": "testUserId", "Category": "yo", "TaskName": "New Task", "Description": "Description of the new task", "StartTime": "2024-01-01T08:00:00Z", "EndTime": "2024-01-01T17:00:00Z", "Status": "completed", "IsRecurring": false, "IsAllDay": false, "Difficulty": "easy", "CronExpression": "" //for now, recurring functions are not supported } } - Response:
- Status Code: 200 OK
- Body: JSON Sample Response Body
{ "message": "Success", "taskID": 503 }
- Endpoint:
/api/v1/task/:id- NOTE: Replace
:idwith the actual TaskID.
- NOTE: Replace
- Description: Delete a task by ID.
- Request Method: DELETE
- URL Parameters:
id(integer): The ID of the task to be deleted.
- Response:
- Status Code: 200 OK
- Endpoint:
/api/v1/getTeamtask/:id- NOTE: Replace
:idwith the actual TeamID.
- NOTE: Replace
- Description: get a teams task by id
- Response:
- same as other task fetch endpoints, an array of tasks
- Endpoint: '/api/v1/addUserTeam/:id/:code'
- id is team id, code is user code
- Description: add a user to a team
- Response:
- 200ok, or error
- Endpoint:
/api/v1/getUserTeams/:code - Description: get teams for theuser with the given code
- Response:
- array of team objects, 200 code
- Endpoint:
/api/v1/getTeamUsers/:id- NOTE:take in a team ID
- Description: sends back user abstraction array, similar to friends function
- Response:
- array of users 200 code
Endpoint: '/api/v1/teamUserDelete/:tid/:code'
- id is team id, code is user code
- Description: deletes the user from the team
-Response:
- 200 ok or error
Endpoint: '/api/v1/deleteTeam/:tid' -NOTE:team id as id -Description:deletes the team, send a delete req. -Response:200 ok
- Description: sends back user abstraction, similar to friends function
Endpoint: '/api/v1/createTeam/:name' -Description:create request -Response:
- 200 ok with teamID
- Endpoint:
/login - Description: Go directly to
{backend_url}/loginto access this endpoint as it loads request headers to send to Auth0. Do not send a GET to/loginor these headers get lost. - Response:
- Status Code: 307
- Redirects to Auth0 and comes back with another redirect to
backend/callback(to confirm logged in token) - You do not need to route to
/callback
- Redirects to Auth0 and comes back with another redirect to
- Status Code: 307
- Endpoint:
/logout - Description: Should return back to the host url (i.e
localhost:8080on manual run). Go directly to{backend_url}/logoutso the backend performs this logic.
- Endpoint:
/signup - Description: Go directly to
{backend_url}/signupto access this endpoint as it loads request headers to send to Auth0. Do not send a GET to/signupor these headers get lost. - Response:
- Status Code: 307
- Similar behavior to
/logoutbut also adds the newly registered user to the Auth0 database