# Exchange Rates

> Public endpoint for fetching current exchange rates between fiat and cryptocurrencies.

The exchange rates endpoint returns a matrix of current exchange rates between all supported currencies — both fiat (USD, EUR, RUB, etc.) and crypto (BTC, ETH, USDT, etc.).

> **INFO:** This is a **public endpoint**. It does not require authentication and does not require `project` or `sign` headers.

## Get exchange rates

`GET /v1/exchange-rates`

### Response example

```json
{
  "state": 0,
  "result": {
    "USD": {
      "USD": "1.00000000",
      "EUR": "0.86090000",
      "RUB": "78.32190000",
      "BTC": "0.00001055",
      "USDT": "1.00000000"
    },
    "BTC": {
      "USD": "94786.69000000",
      "EUR": "81589.12000000",
      "ETH": "29.02345678",
      "USDT": "94786.69000000"
    }
  }
}
```

### How to read the result

The response is a nested object: `result[FROM][TO]` is the exchange rate for 1 unit of `FROM` to `TO`.

- `result["USD"]["RUB"] = 78.32` means 1 USD = 78.32 RUB
- `result["BTC"]["USD"] = 94786.69` means 1 BTC = $94,786.69

## PHP example

```php
<?php
$ch = curl_init('https://api.2328.io/api/v1/exchange-rates');
curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true ]);

$response = json_decode(curl_exec($ch), true);

if ($response['state'] === 0) {
    $rates = $response['result'];
    $rubAmount = bcmul(100, $rates['USD']['RUB'], 2);
    echo "100 USD = {$rubAmount} RUB\n";
}
```

## cURL example

```bash
curl https://api.2328.io/api/v1/exchange-rates
```

> **WARNING:** Rates are updated frequently but are not guaranteed for trading. Always re-fetch rates just before creating a payment or payout to minimize slippage.