> ## Documentation Index
> Fetch the complete documentation index at: https://docs.finzaria.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Construir un reporte de gastos

> Resumen del periodo y desglose por categoría con dos llamadas.

Objetivo: armar un reporte de un periodo — cuánto entró/salió y en qué se fue el gasto.

## 1. Resumen del periodo

`GET /v1/reports/transaction-summary` te da entradas, salidas y neto del rango:

```bash theme={null}
curl "https://api.finzaria.com/v1/reports/transaction-summary?startDate=2026-07-01&endDate=2026-07-31" \
  -H "Authorization: Bearer $FINZARIA_API_KEY"
```

```json theme={null}
{ "inflow": "25000.00", "outflow": "5244.62", "net": "19755.38", "currency": "MXN" }
```

## 2. Desglose por categoría

`GET /v1/reports/spending-by-category` reparte el gasto por categoría en el mismo rango
(`kind=expense` para gasto, `income` para ingreso; `accountId` opcional para filtrar por cuenta):

```bash theme={null}
curl "https://api.finzaria.com/v1/reports/spending-by-category?startDate=2026-07-01&endDate=2026-07-31&kind=expense" \
  -H "Authorization: Bearer $FINZARIA_API_KEY"
```

## 3. Únelos

<CodeGroup>
  ```javascript Node.js theme={null}
  const q = "startDate=2026-07-01&endDate=2026-07-31"
  const headers = { Authorization: `Bearer ${process.env.FINZARIA_API_KEY}` }

  const [summary, byCategory] = await Promise.all([
    fetch(`https://api.finzaria.com/v1/reports/transaction-summary?${q}`, { headers }).then((r) => r.json()),
    fetch(`https://api.finzaria.com/v1/reports/spending-by-category?${q}&kind=expense`, { headers }).then((r) => r.json()),
  ])

  console.log(`Salió ${summary.outflow} ${summary.currency}, neto ${summary.net}`)
  console.table(byCategory)
  ```
</CodeGroup>

<Tip>
  Los montos consolidados vienen en la [moneda base](/guias/conceptos/multi-divisa); si hay mezcla de
  monedas, el reporte marca los totales como aproximados e incluye la fecha de las tasas.
</Tip>
