This documentation covers the various endpoints available in the Expense Manager API. The base URL for the API is https://expense-manager-w.onrender.com
.
- Method:
POST
- Description: Register a new user.
- Request Body:
{ "username": "string", "password": "string" }
- Response:
- 201 Created:
{ "message": "User registered successfully" }
- 400 Bad Request:
{ "error": "Username already exists" }
- 201 Created:
- Method:
POST
- Description: Log in and obtain a JWT token.
- Request Body:
{ "username": "string", "password": "string" }
- Response:
- 200 OK:
{ "access_token": "jwt_token" }
- 401 Unauthorized:
{ "error": "Invalid username or password" }
- 200 OK:
- Method:
POST
- Description: Add a new expense category.
- Headers:
Authorization: Bearer <JWT_TOKEN>
- Request Body:
{ "name": "string", "description": "string", "image_url": "string" }
- Response:
- 201 Created:
{ "id": "int", "name": "string", "description": "string", "image_url": "string" }
- 201 Created:
- Method:
POST
- Description: Add a new expense.
- Headers:
Authorization: Bearer <JWT_TOKEN>
- Request Body:
{ "amount": "float", "category_id": "int", "description": "string", "date": "YYYY-MM-DD" }
- Response:
- 201 Created:
{ "id": "int", "amount": "float", "category_id": "int", "description": "string", "date": "YYYY-MM-DD", "category_image_url": "string", "is_deleted": "boolean" }
- 400 Bad Request:
{ "error": "Category not found" }
- 201 Created:
- Method:
GET
- Description: Retrieve all expenses.
- Headers:
Authorization: Bearer <JWT_TOKEN>
- Response:
- 200 OK:
[ { "id": "int", "amount": "float", "category_id": "int", "description": "string", "date": "YYYY-MM-DD", "category_image_url": "string", "is_deleted": "boolean" }, ... ]
- 200 OK:
- Method:
DELETE
- Description: Mark an expense as deleted.
- Headers:
Authorization: Bearer <JWT_TOKEN>
- Path Parameters:
id
: ID of the expense to delete.
- Response:
- 200 OK:
{ "message": "Expense deleted successfully", "expense": { "id": "int", "amount": "float", "category_id": "int", "description": "string", "date": "YYYY-MM-DD", "is_deleted": "boolean" } }
- 404 Not Found:
{ "error": "Expense not found" }
- 200 OK:
- Method:
GET
- Description: Retrieve all deleted expenses.
- Headers:
Authorization: Bearer <JWT_TOKEN>
- Response:
- 200 OK:
[ { "id": "int", "amount": "float", "category_id": "int", "description": "string", "date": "YYYY-MM-DD", "category_image_url": "string", "is_deleted": "boolean" }, ... ]
- 200 OK:
All endpoints except /register
and /login
require authentication. Obtain a JWT token from the /login
endpoint and include it in the Authorization
header of your requests in the format Bearer <JWT_TOKEN>
.
The API uses standard HTTP status codes to indicate the success or failure of a request. Responses include descriptive error messages to assist in debugging.
Use tools like Postman, Insomnia, or curl
to interact with the API. Ensure to replace placeholder values (like <JWT_TOKEN>
) with actual data received from the API.