Rates

Rates provide aggregated price and volume data for cryptocurrencies across all exchanges. They represent the consolidated market data that Coinranking calculates for each coin.

The fastest way to get new rates is to subscribe to our WebSockets. You can request rates through our coins endpoints too, but they will only update once a minute. With our WebSockets you can establish a persistent connection through which new rates are pushed, so you get the latest price and 24 hour volume whenever they are calculated.

Authentication

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/rates?x-access-token=your-api-key

Connection Setup

Professional This websocket requires the professional plan or higher

Establish a WebSocket connection to get rates in real-time.

wss://api.coinranking.com/v2/real-time/rates

You can subscribe to rates in two ways:

  1. URL Query Parameters: Specify subscriptions directly in the connection URL
  2. Subscription Messages: Send JSON messages through the WebSocket after connecting to update your subscription

URL Query Parameters

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.

Parameter Description
currency-uuids[] Array

With the currency UUIDs parameter, you can select which coins to subscribe to.

Provide a list of coin UUIDs to make your selection, use our other endpoints or our website to find the UUIDs of coins you want. There is a maximum of hundred UUIDs you can subscribe to within one WebSocket. You can find UUIDs for all our coins in our dedicated reference currency endpoint

Note: Use array notation in the URL: currency-uuids[]=Qwsogvtv82FCd

Size range: 1-100

Example:
wss://api.coinranking.com/v2/real-time/rates?currency-uuids[]=Qwsogvtv82FCd¤cy-uuids[]=razxDUgYGNAdQ
throttle (optional) String

With the throttle parameter, you prevent getting overloaded with 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 coin. If you select a throttle, this means rates for the same coin will not be pushed more than once within the specified duration. When you have subscribed to multiple coins, you still receive more messages within the specified duration.

You can choose between 1s (at least one second interval between a rate for each coin) or 10s (ten seconds).

Default value: 1s
Allowed values: 1s 10s

Example:
wss://api.coinranking.com/v2/real-time/rates?throttle=10s
list (optional) String

CRITICAL: This parameter is ONLY available via URL query strings and cannot be used in subscription messages. When using list=all, you do not need to specify currency-uuids[] as you will receive all rates automatically.

With the list parameter, you can subscribe to a list of coins. When set to all, you will receive rate updates for every cryptocurrency tracked by Coinranking.

The default is none, which means no list is selected and you must use the currency-uuids[] parameter to filter the list.

Default value: none
Allowed values: none all

Example:
wss://api.coinranking.com/v2/real-time/rates?list=all

Subscription Messages

After establishing a WebSocket connection, you can update your subscription by sending JSON messages through the socket. This allows you to change which currencies 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:

json
{ "throttle": "10s", "currencyUuids": ["Qwsogvtv82FCd", "razxDUgYGNAdQ"] }

After sending a subscription message, the server will respond with a confirmation message (see Server Responses below).

Code examples

Responses

The WebSocket server sends different types of messages depending on the context:

Data Messages

When subscribed to rates, you receive aggregated price and volume data for cryptocurrencies. Rates represent consolidated market data calculated by Coinranking across all exchanges, providing a single unified price and 24-hour volume for each coin. Each rate message includes the currency UUID to identify which cryptocurrency the data represents, making it easy to track multiple coins simultaneously.

json
{ "currencyUuid": "Qwsogvtv82FCd", "price": "125423.835504191964312353", "volume": "6270550403.287645846237386287" }

Confirmation Messages

After sending a subscription update message through the WebSocket, the server responds with a confirmation message:

json
{ "type": "confirmation", "topic": "rate", "throttle": "10s", "subscriptions": ["Qwsogvtv82FCd", "razxDUgYGNAdQ"] }

This confirmation indicates that your subscription has been successfully updated.

Response Fields

When subscribed to one or more coins, you receive new rates whenever they are available. Each of these rates includes the UUID of the coin the rate pertains to, which is especially useful when you are subscribed to multiple coins. Rates include the latest price and 24-hour moving volume, both in US dollars.

Unlike our coin endpoints, we do not support other reference currencies than US dollars with WebSockets. You can, however, subscribe to multiple coins, which allows you to calculate them yourself.

PropertyDescription
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.

price String

The latest price of a coin, in US Dollar.

volume String

The latest 24 hour volume of this coin (a moving sum), in US Dollar.