Welcome to the Expense Manager API! This is a simple REST API created using Spring Boot and PostgreSQL. It provides a robust platform for managing expenses, allowing users to authenticate, manage profiles, and perform CRUD operations on expenses. It is designed to be user-friendly and highly customizable.
- Secure User Authentication
- User Profile Management
- Effortless CRUD Operations for Expenses
- Smart Expense Retrieval Based on Logged-In User:
-
Clone the repository:
git clone https://github.com/iamkibeh/expense-manager-api.git
-
Navigate to the project directory
cd expense-manager-api
-
Build the project using Maven
mvn clean install
- Update
application.properties
with your database and application configuration. - Customize other configuration files as needed.
Method | URL | Description | Return |
---|---|---|---|
POST | api/v1/auth/register | User registration | User object |
POST | api/v1/auth/login | User login | JSON Web Token (jwt) |
Method | URL | Description | Return |
---|---|---|---|
GET | api/v1/expenses | Get all user expenses | Array of JSON objects |
GET | api/v1/expenses/{id} | Get a specific user expenses by id | Single JSON objects |
GET | api/v1/expenses/name?name={name} | Filter expenses by name | Array of filtered JSON objects |
GET | api/v1/expenses/category?category={category} | Filter expenses by name | Array of filtered JSON objects |
POST | api/v1/expenses | Create a user expenses | Created JSON objects |
PUT | api/v1/expenses/{id} | Update a user expenses | Updated JSON objects |
DELETE | api/v1/expenses/{id} | Delete a user expenses | No content |
** NOTE: ** The endpoints of
Expenses
are restricted. To access these endpoints, use the token generated after logging in as the value of Bearer in the Authorization header as follows: "Authorization: Bearer Token_id"You can also retrieve expenses with optional pagination and sorting.
- Parameters:
-
page
(optional): Page number for pagination. Defaults to 0. -
size
(optional): Number of items per page. Defaults to a configured value. -
sort
(optional): Sorting order. Example:sort=id,desc
. -
Example Request:
GET /api/v1/expenses?page=0&size=3&sort=id,desc
- Example Response:
{ "content": [ { "id": 2, "name": "Food", "description": "this is expense 2", "amount": 200.00, "category": "expense", "date": "2024-01-29", "createdAt": "2024-01-30T05:03:23.710+00:00", "updatedAt": "2024-01-30T05:03:23.710+00:00" } // Additional expenses... ], "pageable": { "pageNumber": 0, "pageSize": 3, "sort": { "sorted": true, "unsorted": false, "empty": false } }, "totalElements": 10, "totalPages": 4, "last": false, "first": true, "sort": { "sorted": true, "unsorted": false, "empty": false }, "numberOfElements": 3, "size": 3, "number": 0, "empty": false }
-
POST api/v1/auth/register
Content-Type: application/json
{
"email": "[email protected]",
"password": "12345678",
"name": "liam"
}
POST api/v1/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "12345678",
}
GET api/v1/profile
Authorization: Bearer your_auth_token
POST api/v1/expenses
Authorization: Bearer your_auth_token
Content-Type: application/json
{
"name": "Expense 1",
"description": "this is my test expense",
"amount": 18000,
"category": "expense",
"date": "2023-10-30"
}
If you'd like to contribute, please fork the repository and create a new branch. Pull requests are welcome!
This project is licensed under the MIT License.