Exchange rates show the price and volume of specific cryptocurrencies on individual exchanges, unlike rates, which aggregate data from multiple exchanges.
The fastest way to get new exchange rates is to subscribe to our WebSockets. You can request rates through our exchange coin listings endpoints too, but they will only update once a minute. With our WebSockets you can establish a persistent connection through which new exchange rates are pushed, so you get the latest price and 24 hour volume whenever they are calculated.
The WebSocket protocol does not support regular HTTP headers, so it is not possible to use the x-access-token header when opening a new WebSocket. Authenticate to our WebSockets connections using a query parameter:
wss://api.coinranking.com/v2/real-time/exchange-rates?x-access-token=your-api-key
Establish a WebSocket connection to get exchange rates in real-time.
wss://api.coinranking.com/v2/real-time/exchange-rates
You can subscribe to exchange rates in two ways:
You can specify your subscription preferences directly in the WebSocket connection URL using query parameters. This is the recommended approach when you know your subscription requirements at connection time.
Important: You must choose only ONE of the following subscription parameters: references, exchange-uuids, currency-uuids, or list. You cannot mix different parameter types.
| Parameter | Description |
|---|---|
references[] Array |
Subscribe to specific exchange-currency pairs. Each reference must follow the format: This allows you to get rates for specific trading pairs on specific exchanges.
Note: Use array notation in the URL: Example:
wss://api.coinranking.com/v2/real-time/exchange-rates?references[]=-zdvbieRdZ_Qwsogvtv82FCd
|
exchange-uuids[] Array |
Subscribe to all rates for specific exchanges. This will give you all currency rates available on the selected exchanges. Provide a list of exchange UUIDs to make your selection. You can find exchange UUIDs in our exchanges endpoint
Note: Use array notation in the URL: Example:
wss://api.coinranking.com/v2/real-time/exchange-rates?exchange-uuids[]=-zdvbieRdZ
|
currency-uuids[] Array |
Subscribe to all rates for specific currencies across all exchanges. This will give you rates for the selected currencies from all available exchanges. Provide a list of currency UUIDs to make your selection. You can find currency UUIDs in our reference currencies endpoint
Note: Use array notation in the URL: Example:
wss://api.coinranking.com/v2/real-time/exchange-rates?currency-uuids[]=Qwsogvtv82FCd
|
list (optional) String |
CRITICAL: This parameter is ONLY available via URL query strings and cannot be used in subscription messages. When using
With the list parameter, you can subscribe to all exchange rates. When set to
The default is Allowed values: none all Example:
wss://api.coinranking.com/v2/real-time/exchange-rates?list=all
|
throttle (optional) String |
With the throttle parameter, you prevent getting overloaded with exchange rates. This is useful if performance is an issue, e.g. when using WebSockets in your frontend and want to prevent straining your client's devices too much. Throttling works per exchange-currency pair. If you select a throttle, this means rates for the same pair will not be pushed more than once within the specified duration. Default value: 1sAllowed values: 1s 10s Example:
wss://api.coinranking.com/v2/real-time/exchange-rates?throttle=10s
|
After establishing a WebSocket connection, you can update your subscription by sending JSON messages through the socket. This allows you to change which exchange rates you're subscribed to without reconnecting.
Important: The list parameter is NOT supported in subscription messages. It can only be used in URL query strings when initially connecting.
Send a JSON message with the following structure. Note that you must choose only ONE subscription type per message:
json{
"exchangeUuids": ["-zdvbieRdZ", "TjMe3QlK0"],
"throttle": "10s"
}
Or using currency UUIDs:
json{
"currencyUuids": ["Qwsogvtv82FCd"],
"throttle": "10s"
}
Or using references:
json{
"references": ["-zdvbieRdZ_Qwsogvtv82FCd"],
"throttle": "10s"
}
After sending a subscription message, the server will respond with a confirmation message (see Server Responses below).
The WebSocket server sends different types of messages depending on the context:
When subscribed to exchange rates, you receive price and volume updates for specific exchange-currency pairs. Each message includes both the exchange UUID and currency UUID, allowing you to identify which exchange the rate comes from and which cryptocurrency it represents. This is particularly useful when tracking the same currency across different exchanges or monitoring multiple trading pairs.
json{
"exchangeUuid": "-zdvbieRdZ",
"currencyUuid": "Qwsogvtv82FCd",
"exchangeType": "cex",
"price": "125423.835504191964312353",
"volume": "6270550403.287645846237386287"
}
After sending a subscription update message through the WebSocket, the server responds with a confirmation message:
json{
"type": "confirmation",
"topic": "exchange-rate",
"throttle": "10s",
"subscriptions": ["exchange:-zdvbieRdZ", "exchange:TjMe3QlK0"]
}
When subscribed to exchange rates, you receive new rates whenever they are available. Each exchange rate includes the UUID of both the exchange and currency, which is especially useful when you are subscribed to multiple exchanges or currencies. Exchange rates include the latest price and 24-hour moving volume, both in US dollars.
Unlike our exchange coin listings endpoints, we do not support other reference currencies than US dollars with WebSockets. You can, however, subscribe to multiple exchanges and currencies, which allows you to calculate them yourself.
| Property | Description |
|---|---|
exchangeUuid String | The exchange UUID of this rate. Useful if you subscribed to multiple exchanges, in which case the UUID helps you determine which exchange the rate comes from. |
currencyUuid String | The currency UUID of this rate. Useful if you subscribed to multiple currencies, in which case the UUID helps you determine to what coin the rate belongs. |
exchangeType String | The type of exchange: |
price String | The latest price of the coin on this exchange, in US Dollar. |
volume String | The latest 24 hour volume of this currency on this exchange (a moving sum), in US Dollar. |