Skip to content

Trade Channel ​

wss://api.valr.com/ws/trade

The Trade WebSocket channel provides real-time market data including order book updates, trades, and market summaries.

Authentication ​

The Trade channel supports both authenticated and unauthenticated connections. Unauthenticated connections can receive all market data events but are automatically disconnected after 15 minutes.

To authenticate (optional):

Connection Headers ​

Authentication is performed by passing HTTP headers during the WebSocket handshake. The following headers are required:

HeaderDescription
X-VALR-API-KEYYour API key
X-VALR-SIGNATUREHMAC-SHA512 signature (see below)
X-VALR-TIMESTAMPCurrent Unix timestamp in milliseconds

The signature is computed as:

Signature = HMAC-SHA512(API_SECRET, TIMESTAMP + "GET" + "/ws/trade")

Example connection:

javascript
const WebSocket = require('ws');

const headers = {
    'X-VALR-API-KEY': 'YOUR_API_KEY',
    'X-VALR-SIGNATURE': signature,
    'X-VALR-TIMESTAMP': timestamp
};

const ws = new WebSocket('wss://api.valr.com/ws/trade', { headers });

Subscribing to Events ​

All Trade channel events require an explicit subscription. You can optionally filter by currency pairs:

json
{
    "type": "SUBSCRIBE",
    "subscriptions": [
        {
            "event": "AGGREGATED_ORDERBOOK_UPDATE",
            "pairs": ["BTCZAR", "ETHZAR"]
        },
        {
            "event": "NEW_TRADE",
            "pairs": ["BTCZAR"]
        },
        {
            "event": "MARKET_SUMMARY_UPDATE"
        }
    ]
}

If pairs is omitted, you receive events for all available currency pairs.

To unsubscribe from an event, send a SUBSCRIBE message with an empty pairs array for that event. This removes all pair subscriptions, effectively unsubscribing you:

json
{
    "type": "SUBSCRIBE",
    "subscriptions": [
        {
            "event": "AGGREGATED_ORDERBOOK_UPDATE",
            "pairs": []
        }
    ]
}

Events ​

EventDescription
AGGREGATED_ORDERBOOK_UPDATEFull order book aggregated by price level
NEW_TRADENew trades with price, quantity, and taker side
MARKET_SUMMARY_UPDATEMarket statistics including bid/ask, volume, and 24-hour change

Message Format ​

Trade events include the currency pair in the message:

json
{
    "type": "EVENT_TYPE",
    "currencyPairSymbol": "BTCZAR",
    "data": { ... }
}

For full payload schemas, see the individual operation pages in the sidebar.