Overview
The Reports API provides comprehensive financial analytics including charts, summaries, and data export functionality. Generate insights across different time periods and filter by wallet. Base Path:/api/reports
Authentication: Required (session-based)
Get Report Data
Retrieve comprehensive financial analytics including pie charts, bar charts, line charts, and spending summaries./api/reports/data
Query Parameters
Time period for the report:
this_month(default) - Current calendar monthlast_month- Previous calendar monthyear- Entire current year
Filter by specific wallet ID, or
all (default) for all walletsTransaction type for certain charts:
expense(default) - Chi tiêuincome- Thu nhập
Response Structure
Category distribution for the selected transaction type
Total amounts by transaction type
Trend analysis over time
Top expense categories ranked by amount
Financial summary totals
Example Request
Example Response
Implementation Details
Source:app/routes/report.py:52-129
Export to Excel
Download transaction data as an Excel spreadsheet./api/reports/export/excel
Query Parameters
Time period to export:
this_month(default)last_monthyear
Response
Returns an Excel file (.xlsx) with transaction data.
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Filename Format: Bao_cao_{time_range}_{date}.xlsx
Excel File Structure
| Column | Description |
|---|---|
| Ngày | Transaction date (DD/MM/YYYY) |
| Danh mục | Category name (or “Chưa phân loại”) |
| Nội dung | Transaction description |
| Số tiền | Amount |
| Loại | Type: “Chi tiêu”, “Thu nhập”, or “Chuyển khoản” |
| Ví | Wallet name |
Example Request
Implementation Details
Source:app/routes/report.py:131-163
Export to PDF
Generate a formatted PDF report with transaction details and summary./api/reports/export/pdf
Query Parameters
Time period to export:
this_month(default)last_monthyear
Response
Returns an HTML page rendered for PDF conversion (designed for browser print-to-PDF). Content-Type:text/html
PDF Report Contents
- Report header with date range
- User name and generation date
- Summary totals (income, expenses)
- Detailed transaction table:
- Date
- Category
- Description
- Amount
- Type
- Wallet
Example Request
Implementation Details
Source:app/routes/report.py:165-192
- Renders
user/pdf_report.htmltemplate - Includes print-optimized CSS
- Users typically use browser’s “Print to PDF” functionality
- Template receives:
transactions: Full transaction liststart_date,end_date: Date rangetotal_income,total_expense: Summary totalsuser_name: From sessiontoday: Current date
Date Range Helper
Internal function used by all report endpoints:Error Codes
| Status Code | Description |
|---|---|
| 200 | Request successful |
| 401 | Unauthorized (not logged in) |
| 500 | Database error or report generation failed |
Performance Notes
Related Endpoints
- Transactions API - Source data for reports
- Wallets API - Filter reports by wallet
- AI Services API - AI-powered insights complement reports
