Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/astrxnomo/financial-analytics-agent/llms.txt

Use this file to discover all available pages before exploring further.

The Finance REST API is a set of read-only HTTP endpoints that expose the same analytical queries powering the AI agent. Every route under /api/finance/ is a thin wrapper around agent/lib/finance.ts — the shared library that both the REST routes and the agent’s authored tools call into directly. This means the REST API and the agent always return identical numbers for the same inputs; there is no separate data path, no synchronisation lag, and no extra service to run.

Base URL

All endpoints are served from the same origin as the Next.js application. There is no separate API service and no base-URL environment variable to configure.
http://localhost:3000/api/finance/   # local development
https://<your-vercel-domain>/api/finance/   # production
Because the API is co-located with the frontend at the same origin, there are no CORS restrictions on same-origin requests. Cross-origin clients may make requests freely in the demo configuration.

Authentication

No authentication is required. The eve channel is configured with none() auth, which means all /api/finance/* endpoints are publicly accessible in the current demo setup. Before pointing the application at real (non-synthetic) financial data, replace none() in agent/channels/eve.ts with a real auth provider such as vercelOidc() and add equivalent middleware to the REST routes.

All Endpoints

MethodPathDescription
GET/api/finance/summaryTotal income, expense, and net profit over a date range
GET/api/finance/trendMonthly time series of income or expense, optionally grouped by department
GET/api/finance/category-breakdownMonthly totals per spending or revenue category
GET/api/finance/cashflowMonthly income, expense, net, and cumulative net profit
GET/api/finance/budget-statusBudget vs actual expense per department for a single month
GET/api/finance/anomaliesExpense transactions that exceed the per-category statistical baseline
GET/api/finance/profitabilityIncome, expense, net profit, and margin per department for a date range
GET/api/finance/data-overviewDataset metadata: date coverage, row counts, department and category counts
GET/api/finance/highlightsRicher dataset meta including fastest-growing category, most over-budget department, and top anomaly (used by the chat UI’s suggested question chips)

Error Handling

Every route that accepts query parameters validates them against a Zod schema using the shared parseQuery helper (agent/lib/api-route.ts). If validation fails, the route returns a 400 Bad Request response with a JSON body describing the validation errors:
{
  "error": {
    "formErrors": [],
    "fieldErrors": {
      "from": ["Required"],
      "to": ["Required"]
    }
  }
}
On success, all routes return 200 OK with a JSON body. There are no partial-success or pagination envelopes — the full result set is returned in a single response.

Date Format

All date parameters (from, to, and month) are plain YYYY-MM-DD strings. Dates are inclusive on both ends: a request with from=2025-01-01&to=2025-03-31 includes all transactions on both January 1 and March 31. The month parameter accepted by /budget-status is truncated to the first of the month internally, so passing any date within the target month (e.g. 2025-06-15) is equivalent to passing 2025-06-01.
These endpoints share the same analytics library as the agent tools. Any change to agent/lib/finance.ts is automatically reflected in both the REST API and the agent.

Endpoint Pages

GET /summary

Total income, expense, and net profit for a date range.

GET /trend

Monthly time series of income or expense, with optional department grouping.

GET /category-breakdown

Monthly totals broken down by spending or revenue category.

GET /cashflow

Monthly cash flow series with cumulative net profit.

GET /budget-status

Budget vs actual expense per department for a single month.

GET /anomalies

Statistical outlier transactions flagged by per-category mean and stddev.

GET /profitability

Income, expense, net profit, and margin per department for a date range.

GET /data-overview

Dataset metadata: date coverage, transaction counts, and category breakdown.

GET /highlights

Richer dataset meta used by the chat UI’s suggested question chips.

Build docs developers (and LLMs) love