The Expense Tracker API is a RESTful service for managing family expenses and incomes. It provides authentication via JWT tokens and supports CRUD operations for expenses and incomes.
- Development:
http://localhost:8080 - Production:
https://your-domain.com
All endpoints (except registration and login) require a JWT token in the Authorization header:
Authorization: Bearer <your-jwt-token>
- POST
/auth/register - Description: Creates a new user account
- Request Body:
{
"username": "string",
"email": "string",
"password": "string",
"registrationCode": "string"
}- Response (201 Created):
{
"token": "jwt-token",
"user": {
"id": "string",
"username": "string",
"email": "string"
}
}- POST
/auth/login - Description: Authenticates a user and returns JWT token
- Request Body:
{
"username": "string",
"password": "string"
}- Response (200 OK):
{
"token": "jwt-token",
"user": {
"id": "string",
"username": "string",
"email": "string"
}
}- GET
/expenses/categories - Description: Returns all available expense categories
- Response (200 OK):
[
"groceries",
"utilities",
"entertainment",
"transportation",
"healthcare",
"education",
"shopping",
"dining",
"travel",
"other"
]- GET
/expenses - Description: Returns all expenses for the family
- Response (200 OK):
[
{
"id": "string",
"userId": "string",
"amount": 100.50,
"category": "groceries",
"description": "Weekly groceries",
"isRecurring": false,
"startDate": "2024-01-01",
"createdAt": "2024-01-01T10:00:00Z"
}
]- POST
/expenses - Description: Creates a new expense record
- Request Body:
{
"amount": 100.50,
"category": "groceries",
"description": "Weekly groceries",
"isRecurring": false,
"startDate": "2024-01-01"
}- Response (201 Created):
{
"id": "expense-id"
}- PUT
/expenses/{id} - Description: Updates an existing expense record
- Request Body: Same as Create Expense
- Response (200 OK): Empty response
- DELETE
/expenses/{id} - Description: Deletes an expense record
- Response (200 OK): Empty response
- GET
/incomes - Description: Returns all incomes for the family
- Response (200 OK):
[
{
"id": "string",
"userId": "string",
"amount": 5000.00,
"description": "Monthly salary",
"isRecurring": true,
"startDate": "2024-01-01",
"createdAt": "2024-01-01T10:00:00Z"
}
]- POST
/incomes - Description: Creates a new income record
- Request Body:
{
"amount": 5000.00,
"description": "Monthly salary",
"isRecurring": true,
"startDate": "2024-01-01"
}- Response (201 Created):
{
"id": "income-id"
}- PUT
/incomes/{id} - Description: Updates an existing income record
- Request Body: Same as Create Income
- Response (200 OK): Empty response
- DELETE
/incomes/{id} - Description: Deletes an income record
- Response (200 OK): Empty response
enum class ExpenseCategory {
GROCERIES,
UTILITIES,
ENTERTAINMENT,
TRANSPORTATION,
HEALTHCARE,
EDUCATION,
SHOPPING,
DINING,
TRAVEL,
OTHER
}All endpoints may return the following error responses:
{
"error": "Invalid request data"
}{
"error": "Invalid token"
}{
"error": "Invalid registration code"
}{
"error": "Resource not found"
}{
"error": "Username already exists"
}{
"error": "Internal server error"
}You can import the ExpenseTracker_API.postman_collection.json file into Postman for interactive testing of all endpoints.
Currently, there are no rate limits implemented. Consider implementing rate limiting for production use.
- Passwords are hashed using SHA-256 (consider using bcrypt for production)
- JWT tokens expire after 24 hours
- Registration requires a valid registration code
- All sensitive endpoints require authentication