# Balance history

Returns a balance history for the specified XPUB or address.

This method will use `10` [Compute Units](/v1/about/billing.md).

***

## **Reference:** [**Here**](https://github.com/trezor/blockbook/blob/master/docs/api.md#balance-history)

```bash
GET /api/v2/balancehistory/<XPUB | address>?from=<dateFrom>&to=<dateTo>[&fiatcurrency=<currency>&groupBy=<groupBySeconds>]
```

## **Parameters**

Required parameters

**`XPUB or address`**- string, required.

Example: `bc1q262qeyyhdakrje5qaux8m2a3r4z8sw8vu5mysh` (address)\
\
\&#xNAN;**`dateFrom`**- Unix timestamp, required.

Example: `1704067200`

**`dateTo`**- Unix timestamp, required.

Example: `1715160143`

Optional parameters

* ***`fiatcurrency`***: if specified, the response will contain secondary (fiat) rate at the time of transaction. If not, all available currencies will be returned.
* ***`groupBy`***: an interval in seconds, to group results by. Default is 3600 seconds.

## Returns

Example response (fiatcurrency=usd):

```bash
[
	{
		"time": 1708239600,
		"txs": 9,
		"received": "2970",
		"sent": "0",
		"sentToSelf": "0",
		"rates": {
			"usd": 51518.35
		}
	},
	....
	{
		"time": 1715144400,
		"txs": 1,
		"received": "2310",
		"sent": "0",
		"sentToSelf": "0",
		"rates": {
			"usd": 62560.055
		}
	}
]
```

{% tabs %}
{% tab title="mainnet" %}

```bash
curl https://mainnet.bitcoin.validationcloud.io/v1/<YOUR_API_KEY>/api/v2/balancehistory/bc1q262qeyyhdakrje5qaux8m2a3r4z8sw8vu5mysh?from=1704067200&to=1715160143&fiatcurrency=usd \
 -X GET \
 -H "Content-Type: application/json"
```

{% endtab %}

{% tab title="testnet" %}

```bash
curl https://testnet.bitcoin.validationcloud.io/v1/<YOUR_API_KEY>/api/v2/balancehistory/bc1q262qeyyhdakrje5qaux8m2a3r4z8sw8vu5mysh?from=1704067200&to=1715160143&fiatcurrency=usd \
 -X GET \
 -H "Content-Type: application/json"
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.validationcloud.io/v1/bitcoin/blockbook-indexer-rest-api/balance-history.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
