5.6 KiB
5.6 KiB
API Routes
By default, Einsen runs on port 8000. You can change this from
application.conffile insidesrc/main/resources. You'll need to install Postgresql. While installing, please check thePgAdminoption to install it too. It's a web-based GUI tool used to interact with the Postgres database.PS: Please keep the username and password you create while installing Postgresql. You'll need them to connect Einsen Server to Postgresql (locally)
Skip to
- Registering a new user
- To login an existing user
- To create a new task
- To retrieve all the task of the given user
- To update a task
- To delete a task
1. To Register a new user (POST Request)
/api/auth/register
Body
{
"username": "your_username",
"password": "your_password"
}
Rules
---------
Username and Password field should not be blank.
Username and Password length should be between 4 to 10 characters.
Username should not only consists of numbers.
Special characters are not allowed inside username.
--------
This rules are verified on Server side.
Response
{
"success": true,
"additionalMessage": "Account created successfully.",
"data": null
}
2. To Login an existing user (POST Request)
/api/auth/login
Body
{
"username": "your_username",
"password": "your_password"
}
Rules
---------
Username and Password field should not be blank.
--------
This rules are verified on Server side.
Success Response
{
"success": true,
"additionalMessage": null,
"data": {
"userId": "user_id",
"token": "jwt_token"
}
}
Except for login and register routes, every other routes requires you to attach Bearer token of the user retrieved after Login in this format:
| Header Key | Header Value |
|---|---|
Authorization |
Bearer <User Token> |
3. To create a task (POST Request)
/api/task/create
Body
{
"title": "task_title",
"description": "task_description",
"category": "category_name",
"emoji": "x",
"urgency": 0,
"importance": 0,
"priority": 0,
"due": "due_date",
"isCompleted": false
}
Rules
---------
All fields are mandatory, leaving out any one of them will throw 500 Server Error.
Title, description and category field should be of 4 characters or more.
--------
This rules are verified on Server side.
Success Response
{
"success": true,
"additionalMessage": null,
"data": {
"taskID": "newly_created_task_id"
}
}
4. To retrieve all the task (GET Request)
/api/task/get?userId={id}&category={category_name}
| Parameter | Parameter Description |
|---|---|
userId |
To fetch the list of task of the given user ID |
category |
If is empty or null, all tasks regardless of their category would get displayed. |
Success Response
{
"success": true,
"additionalMessage": null,
"data": [
{
"id": "d8d7c578-b8af-459c-865c-3ff518a2b630",
"title": "updated_task_title",
"description": "updated_task_description",
"category": "updated_category_name",
"emoji": "y",
"urgency": 1,
"importance": 1,
"priority": 1,
"due": "updated_due_date",
"isCompleted": true,
"created": 1638331650467,
"updated": 1638331650553
},
{
"id": "d8d7c578-b8af-459c-865c-3ff518a2b630",
"title": "updated_task_title",
"description": "updated_task_description",
"category": "updated_category_name",
"emoji": "y",
"urgency": 1,
"importance": 1,
"priority": 1,
"due": "updated_due_date",
"isCompleted": true,
"created": 1638331650467,
"updated": 1638331650553
}
]
}
5. To update a task (PUT Request)
/api/task/update?taskId={id}
| Parameter | Parameter Description |
|---|---|
taskId |
Task ID which you wish to update |
Body
{
"title": "updated_task_title",
"description": "updated_task_description",
"category": "updated_category_name",
"emoji": "y",
"urgency": 1,
"importance": 1,
"priority": 1,
"due": "updated_due_date",
"isCompleted": true
}
Rules
---------
All fields are mandatory, leaving out any one of them will throw 500 Server Error.
Title, description and category field should be of 4 characters or more.
Task should be of user.
--------
This rules are verified on Server side.
Success Response
{
"success": true,
"additionalMessage": null,
"data": {
"taskID": "task_id"
}
}
6. To delete a task (DELETE Request)
/api/task/delete?taskId={id}
| Parameter | Parameter Description |
|---|---|
taskId |
Task ID which you wish to delete |
Rules
---------
Task should be of user.
--------
This rules are verified on Server side.
Success Response
{
"success": true,
"additionalMessage": null,
"data": {
"taskID": "Success"
}
}
TODO:
- Add
orderByparameter on get all task request. - Verify if response is empty when creating and updating a task (
except
title, description & categoryas they are already been verified).