Exchange Rates
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 them in real-time. You can request rates through our exchange coin listings endpoints too, but they will only update once a minute. A real-time connection pushes new exchange rates as soon as they are calculated, so you get the latest price and 24 hour volume without polling.
Connection Setup
Real-time streaming requires the Professional plan or higher. Your plan’s connection limits and minimum update interval apply.
Exchange rates are available over both transports, with the same query parameters and the same messages:
wss://api.coinranking.com/v2/real-time/exchange-rates
https://api.coinranking.com/v2/real-time/sse/exchange-rates
How to authenticate, connect, and reconnect is described on the WebSockets and Server-Sent Events pages. Not sure which one to use? See choosing a transport.
URL Query Parameters
Add the parameters to either URL, and optionally a throttle.
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:
?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:
?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. Centralized exchange data requires a plan with streaming access. Decentralized exchange data also requires the Real-Time DEX Data add-on. Your plan’s connection limits and minimum update interval apply. 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:
?currency-uuids[]=Qwsogvtv82FCd
|
list String | Subscribe to the rates of all coins on all exchanges instead of a selection. This is a high-volume stream, so make sure your client keeps up with it. Centralized exchange data requires a plan with streaming access. Decentralized exchange data also requires the Real-Time DEX Data add-on. Your plan’s connection limits and minimum update interval apply. Allowed values: allExample:
?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 streaming exchange rates to your frontend and you 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: Your plan’s minimum intervalAllowed values: 1s 5s 10s 30s 60s For plans with streaming access, an omitted throttle uses the plan’s minimum interval (1s on Professional). Faster requests are rejected. Throttle settings do not grant streaming access to other plans. Example:
?exchange-uuids[]=-zdvbieRdZ&throttle=10s
|
Subscription Messages
WebSockets only. On an open WebSocket, you can change your subscription by sending a JSON message, without reconnecting. See subscription messages for how they work. A Server-Sent Events stream cannot be changed: close it and open a new stream with the new parameters instead.
Choose only ONE subscription type per message:
{
"exchangeUuids": ["-zdvbieRdZ", "TjMe3QlK0"],
"throttle": "10s"
} Or using currency UUIDs:
{
"currencyUuids": ["Qwsogvtv82FCd"],
"throttle": "10s"
} Or using references:
{
"references": ["-zdvbieRdZ_Qwsogvtv82FCd"],
"throttle": "10s"
} Code examples
const connection = new WebSocket(
'wss://api.coinranking.com/v2/real-time/exchange-rates?x-access-token=your-api-key&exchange-uuids[]=-zdvbieRdZ&exchange-uuids[]=TjMe3QlK0&throttle=10s'
);
connection.onmessage = (event) => {
const exchangeRate = JSON.parse(event.data);
console.log(exchangeRate);
}; # -N disables output buffering, -g stops curl from interpreting the [] in the URL
curl -N -g 'https://api.coinranking.com/v2/real-time/sse/exchange-rates?exchange-uuids[]=-zdvbieRdZ&exchange-uuids[]=TjMe3QlK0&throttle=10s' \
-H 'x-access-token: your-api-key' More examples, including subscription messages and a fetch-based stream reader, are on the WebSockets and Server-Sent Events pages.
Responses
Data Messages
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.
{
"type": "exchange-rate",
"exchangeUuid": "-zdvbieRdZ",
"currencyUuid": "Qwsogvtv82FCd",
"exchangeType": "cex",
"price": "125423.835504191964312353",
"volume": "6270550403.287645846237386287"
} Confirmation Messages
A confirmation lists what you are subscribed to and with which throttle. A Server-Sent Events stream sends it as its first message; a WebSocket sends it in answer to a subscription message.
{
"type": "confirmation",
"topic": "exchange-rate",
"throttle": "10s",
"subscriptions": ["exchange:-zdvbieRdZ", "exchange:TjMe3QlK0"]
} Response Fields
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 in real-time. You can, however, subscribe to multiple exchanges and currencies, which allows you to calculate them yourself.
| Property | Description |
|---|---|
type String | The kind of message. Always |
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. |