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

# The Spending Analysis object

> Categorized spending breakdown with summary statistics.

The Spending Analysis response provides spending data grouped by category, merchant, or time period, along with summary statistics.

## Summary attributes

| Attribute                  | Type    | Description                  |
| :------------------------- | :------ | :--------------------------- |
| total\_spending            | string  | Total spending amount        |
| average\_daily\_spending   | string  | Average daily spending       |
| average\_monthly\_spending | string  | Average monthly spending     |
| total\_transactions        | integer | Total number of transactions |
| unique\_merchants          | integer | Number of unique merchants   |
| top\_category              | string  | Highest-spending category    |
| top\_merchant              | string  | Highest-spending merchant    |

## Spending data attributes

| Attribute        | Type             | Description                     |
| :--------------- | :--------------- | :------------------------------ |
| by\_category     | array of objects | Spending grouped by category    |
| by\_merchant     | array of objects | Spending grouped by merchant    |
| by\_time\_period | array of objects | Spending grouped by time period |

## Response attributes

| Attribute        | Type             | Description                                                                                                      |
| :--------------- | :--------------- | :--------------------------------------------------------------------------------------------------------------- |
| spending         | object           | Spending data from MyTruv API                                                                                    |
| summary          | object           | Summary statistics                                                                                               |
| request\_id      | string           | Unique request identifier                                                                                        |
| created\_at      | string           | Analysis creation timestamp                                                                                      |
| by\_time\_period | array of objects | Time periods with category/merchant breakdown (only when `group_by=time_period` and `secondary_group_by` is set) |
| total\_income    | string           | Total income (credits) across the period. Null unless `include_income=true`.                                     |
| total\_expenses  | string           | Total expenses (debits) across the period.                                                                       |
| savings\_rate    | string           | Share of income retained, as a percentage. Null unless income is included.                                       |

***

## Endpoints

* [Get spending analysis](/api-reference/spending/get-spending)

***

## Example response

```json theme={null}
{
  "spending": {
    "by_category": [
      {
        "category": "Food & Dining",
        "total_amount": "1250.00",
        "transaction_count": 45,
        "average_transaction": "27.78",
        "percentage_of_total": "24.5"
      }
    ],
    "by_merchant": [
      {
        "merchant_name": "Whole Foods",
        "total_amount": "850.00",
        "transaction_count": 12,
        "average_transaction": "70.83",
        "percentage_of_total": "16.7"
      }
    ]
  },
  "summary": {
    "total_spending": "5100.00",
    "average_daily_spending": "170.00",
    "average_monthly_spending": "5100.00",
    "total_transactions": 249,
    "unique_merchants": 3,
    "top_category": "Food & Dining",
    "top_merchant": "Whole Foods"
  },
  "request_id": "req_abc123",
  "created_at": "2025-03-15T10:00:00Z",
  "total_income": null,
  "total_expenses": "5100.00",
  "savings_rate": null
}
```
