This Readme doc is explain how the back-end of the financial web app Monexo is work.
after success login or new register actions api will generate access_token like :
{
"access_token": "10|UCKQBTCKoAgmpLytlATxHc2KJpKUNd0LLSEhsH7u7c5fa4f5",
"type": "bearer"
}try to save it in localStorage or cookie to use it with your requests, every request must be send with headers:
Accept: must be onlyapplication/jsonAuthorization: containsBearer <token>
Warning
this headers are vary important, every request must contains them to success.
const axios = require("axios");
let config = {
method: "get",
maxBodyLength: Infinity,
url: "http://127.0.0.1:8000/api/transactions",
headers: {
Accept: "application/json",
Authorization: "Bearer 10|UCKQBTCKoAgmpLytlATxHc2KJpKUNd0LLSEhsH7u7c5fa4f5",
},
};
axios
.request(config)
.then((res) => {
console.log(JSON.stringify(res.data));
})
.catch((error) => {
console.log(error);
});{
"status": 200,
"message": "success",
"data": {
//
}
}{
"status": 404,
"message": "failed",
"error": "error details"
}Note
Every failed response will be like this.
{
"status": 403,
"message": "Unauthenticate action !"
}1- POST: /api/login
2- POST: /api/logout
- email (string, email)
- password (string)
{
"access_token": "10|UCKQBTCKoAgmpLytlATxHc2KJpKUNd0LLSEhsH7u7c5fa4f5",
"type": "bearer"
}{
"message": "Logged out successfully"
} POST: /api/register :
- name (string, [you can make `firstName + lastName`])
- email (string, email)
- password (string)
{
"access_token": "10|UCKQBTCKoAgmpLytlATxHc2KJpKUNd0LLSEhsH7u7c5fa4f5",
"type": "bearer"
}1- POST: /api/transactions/create
- title (string, required)
- amount (integer),
- category available:['salary','shopping','home','car','family & personal','git','heathcare','business','rent','food','other'],
- type (only `income` or `expense`),
- description (string, optional)
{
"title": "another transaction",
"type": "income",
"amount": 10000,
"category": "shopping",
"date": "2024-08-08"
}{
"status": 200,
"message": "success",
"data": {
"title": "Buy clothes",
"amount": "500000",
"category": "shopping",
"type": "expense",
"description": "t-shirts",
"user_id": 4,
"updated_at": "2024-12-27T11:58:32.000000Z",
"created_at": "2024-12-27T11:58:32.000000Z",
"id": 43
}
}2- GET: /api/transactions
{
"status": 200,
"message": "success",
"data": {
"current_page": 1,
"data": [
{
"id": 33,
"title": "project salary",
"description": "new balance",
"type": "income",
"amount": "500000.00",
"category": "salary",
"user_id": 4,
"date": null,
"created_at": "2024-12-26T11:06:22.000000Z",
"updated_at": "2024-12-26T11:06:22.000000Z"
},
...
],
"first_page_url": "http://127.0.0.1:8000/api/transactions?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http://127.0.0.1:8000/api/transactions?page=1",
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "http://127.0.0.1:8000/api/transactions?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"next_page_url": null,
"path": "http://127.0.0.1:8000/api/transactions",
"per_page": 15,
"prev_page_url": null,
"to": 8,
"total": 8
}
}2- GET: /api/transactions/{id}
{
"status": 200,
"message": "success",
"data": {
"id": 33,
"title": "project salary",
"description": "new balance",
"type": "income",
"amount": "500000.00",
"category": "salay",
"user_id": 4,
"date": null,
"created_at": "2024-12-26T11:06:22.000000Z",
"updated_at": "2024-12-26T11:06:22.000000Z"
}
}3- PUT: /api/transactions/update/{id}
- title (string)
- amount (integer),
- category_id (integer, required),
- type (only `income` or `expense`),
- description (string, optional)
{
"title": "another transaction",
"type": "income",
"amount": 10000,
"category": "salary",
"date": "2024-08-08"
}{
"status": 200,
"message": "success",
"date": {
"title": "another transaction",
"type": "income",
"amount": 10000,
"category": "other",
"user_id": 4,
"date": "2024-08-08"
}
}4- DELETE: /api/transactions/delete/{id}
{
"status": 200,
"message": "success"
}5- GET: /api/transactions/type/{type?}
- get transactions by type (must be only
incomeorexpense)
{
"status": 200,
"message": "success",
"data": {
"current_page": 1,
"data": [
{
"id": 33,
"title": "project salary",
"description": "new balance",
"type": "{type}",
"amount": "500000.00",
"category": "salary",
"user_id": 4,
"date": null,
"created_at": "2024-12-26T11:06:22.000000Z",
"updated_at": "2024-12-26T11:06:22.000000Z"
},
...
],
"first_page_url": "http://127.0.0.1:8000/api/transactions?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http://127.0.0.1:8000/api/transactions?page=1",
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "http://127.0.0.1:8000/api/transactions?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"next_page_url": null,
"path": "http://127.0.0.1:8000/api/transactions",
"per_page": 15,
"prev_page_url": null,
"to": 8,
"total": 8
}
}6- GET: /api/transactions/date/{date}
dateparam available values: ['today', 'week', 'month', 'year']
{ "status": 200,
"message": "success",
"data": {
"current_page": 1,
"data": [
{
"id": 33,
"title": "project salary",
"description": "new balance",
"type": "income",
"amount": "500000.00",
"category": "salary",
"user_id": 4,
"date": null,
"created_at": "2024-12-26T11:06:22.000000Z",
"updated_at": "2024-12-26T11:06:22.000000Z"
},
...
"first_page_url": "http://127.0.0.1:8000/api/transactions/date/today?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http://127.0.0.1:8000/api/transactions/date/today?page=1",
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "http://127.0.0.1:8000/api/transactions/date/today?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"next_page_url": null,
"path": "http://127.0.0.1:8000/api/transactions/date/today",
"per_page": 15,
"prev_page_url": null,
"to": 8,
"total": 8
}7- GET: /api/transactions/date/get/{date} // e.g. /api/transactions/date/get/2024-12-10
- get transactions for sepicific date .
like point number 6
1- GET: /api/goals
{
"status": 200,
"message": "success",
"data": {
"current_page": 1,
"data": [
{
"id": 1,
"name": "first goal - buy car (update)",
"target_amount": "400000.00",
"current_amount": "3000.00",
"user_id": 4,
"due_date": "2025-05-05",
"created_at": "2024-12-26T06:06:37.000000Z",
"updated_at": "2024-12-26T06:21:12.000000Z"
},
{
"id": 3,
"name": "Buy IPhone",
"target_amount": "400000.00",
"current_amount": "1000.00",
"user_id": 4,
"due_date": "2025-06-05",
"created_at": "2024-12-26T06:24:34.000000Z",
"updated_at": "2024-12-26T06:24:34.000000Z"
}
],
"first_page_url": "http://127.0.0.1:8000/api/goals?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http://127.0.0.1:8000/api/goals?page=1",
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "http://127.0.0.1:8000/api/goals?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"next_page_url": null,
"path": "http://127.0.0.1:8000/api/goals",
"per_page": 15,
"prev_page_url": null,
"to": 2,
"total": 2
}
}2- GET: /api/goals/{id}
{
"status": 200,
"message": "success",
"data": {
"id": 1,
"name": "first goal - buy car (update)",
"target_amount": "400000.00",
"current_amount": "3000.00",
"user_id": 4,
"due_date": "2025-05-05",
"created_at": "2024-12-26T06:06:37.000000Z",
"updated_at": "2024-12-26T06:21:12.000000Z",
"stats": {
"remain_amount": 397000,
"progress": 0.75
}
}
}3- POST: /api/goals/create
- name (string, required)
- target_amount (integer)
- current_amount (integer)
- due_date (date)
{
"status": 200,
"message": "success",
"data":{
"id": 4,
"name": "Buy Labtop",
"target_amount": "10000.00",
"current_amount": "1000.00",
"user_id": 4,
"due_date": "2025-04-01",
"created_at": "2024-12-26T06:24:34.000000Z",
"updated_at": "2024-12-26T06:24:34.000000Z"
}4- PUT: /api/goals/update/{id}
- id (integer)
- name (string, required)
- target_amount (integer)
- current_amount (integer)
- due_date (date)
{
"status": 200,
"message": "success",
"data": {
"id": 4,
"name": "Buy a new HP Labtop",
"target_amount": "10000.00",
"current_amount": "2000.00",
"user_id": 4,
"due_date": "2025-04-01",
"created_at": "2024-12-26T06:24:34.000000Z",
"updated_at": "2024-12-26T06:24:34.000000Z"
}4- DELETE: /api/goals/delete/{id}
{
"status": 200,
"message": "success"
}1- GET: /api/profile
{
"status": 200,
"message": "success",
"data": {
"id": 4,
"name": "mezzzo",
"email": "mazin@exmple.com",
"email_verified_at": null,
"created_at": "2024-12-25T16:36:02.000000Z",
"updated_at": "2024-12-26T09:10:20.000000Z"
}
}2- PUT: /api/profile/reset-password
- old_password (string, required)
- new_password (string, required)
- new_password_confirmation (string)
{
"status": 200,
"message": "success",
"data": "password reset successful"
}3- DELETE: /api/profile/deleteAccount
{
"status": 200,
"message": "success",
"data": "account deleted successful"
}FlushCode, All rights reserved 2024.
Contact: flushcode.team@gmail.com