# Exchange Rate

## Get Exchange Rate

This endpoint provides the current exchange rate for the specified blockchain.

{% code title="HTTP Request" %}

```
GET https://api.whatsonchain.com/v1/<chain>/<network>/exchangerate
```

{% endcode %}

#### Example Request

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

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/bsv/main/exchangerate"
```

{% endtab %}

{% tab title="BTC" %}

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/btc/main/exchangerate"
```

{% endtab %}
{% endtabs %}

#### Example Response

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

```json
{
    "rate": 27.055,
    "time": 1752257180,
    "currency": "USD"
}
```

{% endtab %}

{% tab title="BTC" %}

```json
{
    "rate": 117581.6,
    "time": 1752257200,
    "currency": "USD"
}
```

{% endtab %}
{% endtabs %}

**URL Parameters**

| Parameter | Description                         |
| --------- | ----------------------------------- |
| chain     | Desired blockchain: `bsv` or `btc`. |
| network   | Selected network: `main` or `test`. |

## Get Historical Exchange Rate

This endpoint provides the historical exchange rate data for the specified blockchain.&#x20;

Exchange rate data goes back to:

* `2018/11/19` for BSV.
* `2010/07/18` for BTC.

{% code title="HTTP Request" %}

```
GET https://api.whatsonchain.com/v1/<chain>/main/exchangerate/historical?from=<unixtimestamp>&to=<unixtimestamp>
```

{% endcode %}

#### Example Request

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

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/bsv/main/exchangerate/historical?from=1660139745&to=1660312545"
```

{% endtab %}

{% tab title="BTC" %}

```sh
curl --location --request GET "https://api.whatsonchain.com/v1/btc/main/exchangerate/historical?from=1660139745&to=1660312545"
```

{% endtab %}
{% endtabs %}

#### Example Response

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

```json
[{
    "rate": 60.3905,
    "time": 1660089600
},{
    "rate": 62.661,
    "time": 1660176000
},{
    "rate": 62.9375,
    "time": 1660262400
}]
```

{% endtab %}

{% tab title="BTC" %}

```json
[{
    "rate": 23962.9,
    "time": 1660089600
},{
    "rate": 23935.3,
    "time": 1660176000
},{
    "rate": 24398.7,
    "time": 1660262400
}]
```

{% endtab %}
{% endtabs %}

**URL Parameters**

| Parameter | Description                                                             |
| --------- | ----------------------------------------------------------------------- |
| chain     | Desired blockchain: `bsv` or `btc`.                                     |
| from      | The starting date (`unixtimestamp`) to retrieve the exchange rate data. |
| to        | The end date (`unixtimestamp`) to retrieve the exchange rate data.      |
