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. There are two ways to subscribe to coins; directly establish a connection with subscriptions by using query parameters to select your subscriptions, or establish a connection and send a JSON message through the socket with the subscriptions you require.
wss://api.coinranking.com/v2/real-time/exchange-rates
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. Size range: 1-100Example:
...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 Size range: 1-100Example:
...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 Size range: 1-100Example:
...real-time/exchange-rates?currency-uuids[]=Qwsogvtv82FCd
|
list (optional) String |
With the list parameter, you can subscribe to all exchange rates. When set to all, you will receive rates for all coins from all exchanges. The default is to subscribe to none and filter using other UUID parameters. You can choose between none (no list is selected and you can use the other UUIDs parameter to filter the list) or all (every exchange rate from all exchanges). Default value: noneAllowed values: none all Example:
...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:
...real-time/exchange-rates?throttle=10s
|
json{
"exchangeUuid": "-zdvbieRdZ",
"currencyUuid": "Qwsogvtv82FCd",
"exchangeType": "cex",
"price": "125423.835504191964312353",
"volume": "6270550403.287645846237386287"
}
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. |