-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI_DOCS.txt
More file actions
415 lines (325 loc) · 7.6 KB
/
Copy pathAPI_DOCS.txt
File metadata and controls
415 lines (325 loc) · 7.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# Finexa Backend API Documentation
> Complete API reference for the Finexa financial management platform
**Base URL:** `http://localhost:8000` (Development)
**Authentication:** JWT Bearer Token (except for registration/login endpoints)
**Authorization Header Format:**
```
Authorization: Bearer <access_token>
```
---
## Table of Contents
1. [Authentication](#authentication)
2. [AI Assistant & Document Processing](#ai-assistant--document-processing)
3. [Wallet Management](#wallet-management)
4. [Financial Health Score](#financial-health-score)
5. [Transactions](#transactions)
6. [Savings Goals](#savings-goals)
7. [Gamification](#gamification)
---
## Authentication Endpoints
Base Path: `/auth/`
### 1. Register User
- **POST** `/auth/register/`
- Create a new user account
Request:
{
"username": "string",
"email": "user@example.com",
"password": "string",
"password2": "string"
}
Response (201):
{
"user": {
"id": 1,
"username": "string",
"email": "user@example.com"
},
"tokens": {
"access": "JWT_TOKEN",
"refresh": "REFRESH_TOKEN"
}
}
### 2. Login
- **POST** `/auth/login/`
- Authenticate and get JWT tokens
Request:
{
"email": "user@example.com",
"password": "string"
}
Response (200):
{
"user": {...},
"access": "JWT_TOKEN",
"refresh": "REFRESH_TOKEN"
}
### 3. Refresh Token
- **POST** `/auth/refresh/`
- Get new access token
Request:
{
"refresh": "REFRESH_TOKEN"
}
Response (200):
{
"access": "NEW_JWT_TOKEN"
}
### 4. Get Current User
- **GET** `/auth/me/`
- 🔒 Requires Authentication
- Get authenticated user profile
### 5. Update Profile
- **PUT** `/auth/profile/update/`
- 🔒 Requires Authentication
- Update first_name, last_name, income
### 6. Verify Email
- **POST** `/auth/verify-email/`
- Verify email with token
### 7. Send Verification Email
- **POST** `/auth/send-verification-email/`
- 🔒 Requires Authentication
### 8. Forgot Password
- **POST** `/auth/forgot-password/`
- Request password reset
### 9. Reset Password
- **POST** `/auth/reset-password/`
- Reset password with token
---
## AI Assistant & Document Processing
Base Path: `/api/ai/`
### 10. Process Document
- **POST** `/api/ai/document/process/`
- 🔒 Requires Authentication
- Upload PDF/Image → Extract text → AI analysis → Store data
Form Data: file (PDF/Image, max 10MB)
Response:
{
"success": true,
"document_id": 123,
"mongo_id": "...",
"extracted_text": "...",
"structured_data": {...},
"summary": "AI summary"
}
### 11. List Documents
- **GET** `/api/ai/documents/`
- 🔒 Requires Authentication
- Get all uploaded documents
### 12. Get Document Content
- **GET** `/api/ai/documents/<document_id>/content/`
- 🔒 Requires Authentication
- Get extracted text from document
### 13. Get Expense Summary
- **GET** `/api/ai/expense-document/<mongo_id>/summary/`
- 🔒 Requires Authentication
- AI-generated expense summary
### 14. Get Expense Suggestions
- **GET** `/api/ai/expense-document/<mongo_id>/suggestions/`
- 🔒 Requires Authentication
- Personalized saving suggestions
### 15. Get Chat Sessions
- **GET** `/api/ai/chat-sessions/`
- 🔒 Requires Authentication
- List all chat sessions (paginated)
### 16. Get Chat Messages
- **GET** `/api/ai/chat-sessions/<session_id>/messages/`
- 🔒 Requires Authentication
- Get messages in a chat session
---
## Wallet Management
Base Path: `/api/ai/wallet/`
### 17. Get Wallet
- **GET** `/api/ai/wallet/`
- 🔒 Requires Authentication
- Get wallet balance and info
Response:
{
"id": 1,
"balance": 5000.00,
"currency": "USD"
}
### 18. Add Money
- **POST** `/api/ai/wallet/add-money/`
- 🔒 Requires Authentication
Request:
{
"amount": 1000.00,
"description": "Salary"
}
### 19. Withdraw Money
- **POST** `/api/ai/wallet/withdraw/`
- 🔒 Requires Authentication
Request:
{
"amount": 500.00,
"description": "ATM"
}
### 20. Get Transactions
- **GET** `/api/ai/wallet/transactions/`
- 🔒 Requires Authentication
- Paginated wallet transactions
### 21. Get Timeline
- **GET** `/api/ai/wallet/timeline/`
- 🔒 Requires Authentication
- Timeline view of wallet activity
---
## Financial Health Score
Base Path: `/api/ai/financial-health/`
### 22. Get Current Score
- **GET** `/api/ai/financial-health/score/`
- 🔒 Requires Authentication
- Current financial health score (0-100)
Response:
{
"score": 75,
"grade": "Good",
"trend": "improving"
}
### 23. Get Score History
- **GET** `/api/ai/financial-health/history/`
- 🔒 Requires Authentication
- Historical scores
- Query params: period (week/month/year)
### 24. Get Score Breakdown
- **GET** `/api/ai/financial-health/breakdown/`
- 🔒 Requires Authentication
- Detailed component breakdown
Response:
{
"overall_score": 75,
"components": {
"savings_rate": {"score": 80, "weight": 0.3},
"debt_ratio": {"score": 70, "weight": 0.25},
"emergency_fund": {"score": 75, "weight": 0.25},
"spending_control": {"score": 75, "weight": 0.2}
}
}
### 25. Recalculate Score
- **POST** `/api/ai/financial-health/recalculate/`
- 🔒 Requires Authentication
- Manually trigger score recalculation
### 26. Get Recommendations
- **GET** `/api/ai/financial-health/recommendations/`
- 🔒 Requires Authentication
- Personalized financial recommendations
---
## Transactions
Base Path: `/api/transactions/`
### 27. List Transactions
- **GET** `/api/transactions/`
- 🔒 Requires Authentication
- Get all transactions (paginated)
Response:
{
"count": 100,
"results": [
{
"id": 1,
"amount": 45.50,
"category": "Food",
"type": "expense",
"description": "Grocery",
"date": "2024-01-15"
}
]
}
### 28. Create Transaction
- **POST** `/api/transactions/`
- 🔒 Requires Authentication
Request:
{
"amount": 45.50,
"category": "Food",
"type": "expense",
"description": "Grocery",
"date": "2024-01-15"
}
---
## Savings Goals
Base Path: `/api/goals/`
### 29. List Goals
- **GET** `/api/goals/`
- 🔒 Requires Authentication
Response:
{
"count": 5,
"results": [
{
"id": 1,
"title": "Emergency Fund",
"target_amount": 10000.00,
"current_amount": 5000.00,
"deadline": "2024-12-31",
"progress_percentage": 50,
"status": "in_progress"
}
]
}
### 30. Create Goal
- **POST** `/api/goals/`
- 🔒 Requires Authentication
Request:
{
"title": "Vacation Fund",
"target_amount": 5000.00,
"current_amount": 500.00,
"deadline": "2024-08-31"
}
---
## Gamification
Base Path: `/api/gamification/`
### 31. List Badges
- **GET** `/api/gamification/`
- 🔒 Requires Authentication
Response:
{
"badges": [
{
"id": 1,
"name": "First Save",
"description": "Made first transaction",
"icon": "🎯",
"earned": true,
"earned_at": "2024-01-01T10:00:00Z"
}
],
"total_points": 150,
"level": 3
}
---
## Error Responses
400 Bad Request:
{
"error": "Invalid input",
"details": {"field": ["error"]}
}
401 Unauthorized:
{
"detail": "Authentication credentials were not provided."
}
404 Not Found:
{
"detail": "Not found."
}
---
## Important Notes
### Authentication Flow:
1. Register via /auth/register/ or login via /auth/login/
2. Store access and refresh tokens securely
3. Include access token in Authorization header: "Bearer <token>"
4. Use /auth/refresh/ to get new access token when expired
### Pagination:
Most list endpoints support:
- page: Page number (default: 1)
- page_size: Results per page (default: 10)
### Date Format:
ISO 8601: YYYY-MM-DDTHH:MM:SSZ
### File Uploads:
- Accepted: PDF (.pdf), Images (.jpg, .jpeg, .png)
- Max size: 10MB
---
Created: 2024-01-23
Version: 1.0
Framework: Django REST Framework
Databases: PostgreSQL + MongoDB