MMTMMT Docs
WebSocket

Subscribing

How to subscribe and unsubscribe to real-time data streams, including message formats, field reference, and error codes.

After establishing a WebSocket connection, you can subscribe to real-time data streams by sending JSON messages.

Subscribe Message

To subscribe to a data stream, send a message with the following format:

{
  "type": "subscribe",
  "channel": "candles",
  "exchange": "binancef",
  "symbol": "btc/usd",
  "tf": "1m"
}

You can optionally include an id field for request correlation:

{
  "type": "subscribe",
  "id": "my-request-123",
  "channel": "candles",
  "exchange": "binancef",
  "symbol": "btc/usd",
  "tf": "1m"
}

Unsubscribe Message

To stop receiving data from a stream, send an unsubscribe message:

{
  "type": "unsubscribe",
  "channel": "candles",
  "exchange": "binancef",
  "symbol": "btc/usd",
  "tf": "1m"
}

Message Fields

FieldTypeRequiredDescription
typestringYes"subscribe" or "unsubscribe"
idstringNoOptional client-provided correlation ID (echoed in response)
channelstringYesThe data channel name (see Channels)
exchangestringYesExchange identifier (e.g., binancef, bybitf). Aggregated format: colon-separated, unique, alphabetically ordered IDs (e.g., binancef:bybitf). Invalid aggregate strings return INVALID_EXCHANGE.
symbolstringYesUnified trading pair with slash separator (e.g., btc/usd)
tfstringConditionalTimeframe (required for candles, stats, oi, vd, volumes, heatmap_sd, heatmap_hd, flat_heatmap_sd, flat_heatmap_hd, stop_heatmap, tp_heatmap, liquidation_heatmap)
bucketintegerConditionalBucket group 1-11 (required for vd channel only)

Symbol Field

Use Unified Symbols

Use our unified symbols from the /markets endpoint, not exchange-native tickers like BTCUSDT. See Symbols for details.

The symbol must be in slash format (e.g., btc/usd, not btc-usdt or BTCUSDT):

Correct: "symbol": "btc/usd"

Wrong: "symbol": "BTCUSDT" or "symbol": "btc-usdt"

Exchange Field

For channels that support aggregation, you can subscribe using multiple exchanges in one stream.

Example: "exchange": "binancef:bybitf"

Aggregated exchange strings must be unique and alphabetically ordered. If not, the server responds with INVALID_EXCHANGE and a message such as:

  • invalid aggregated exchange string: exchanges must be ordered alphabetically
  • invalid aggregated exchange string: duplicate exchanges are not allowed

If your tier does not allow multi-exchange realtime aggregation, the server returns AGG_NOT_ALLOWED (for example, on Basic plans).

stop_heatmap, tp_heatmap, and liquidation_heatmap are single-exchange only and available only for hyperliquid and hyperliquid-xyz. If you provide aggregated exchanges for these channels, the server returns INVALID_PARAMS.

Timeframe Field

The tf field is required for channels that aggregate data over time intervals:

  • Required for: candles, stats, oi, vd, volumes, heatmap_sd, heatmap_hd, flat_heatmap_sd, flat_heatmap_hd, stop_heatmap, tp_heatmap, liquidation_heatmap
  • Not used for: trades, depth, liquidations, markets

Valid formats include values like: 1s, 5s, 15s, 30s, 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1W, 1M.

Limits:

  • Minimum: 1s
  • Maximum: 1M (1 month)

Bucket Field

The bucket field is only used with the vd (volume delta) channel:

  • Valid values: 1 through 11
  • Each bucket represents a different price range grouping
  • Tier restrictions may limit available buckets (Basic: bucket 1 only, Pro: buckets 1-11)

Subscription Limits

Each connection has a maximum number of concurrent subscriptions based on your tier:

TierMax Subscriptions per Connection
basic20
pro100

Success Behavior

When a subscription succeeds, the server sends a subscribed acknowledgment message:

{
  "type": "subscribed",
  "id": "my-request-123",
  "channel": "candles",
  "exchange": "binancef",
  "symbol": "btc/usd",
  "tf": "1m"
}
FieldTypeDescription
typestringAlways "subscribed"
idstringYour correlation ID (if provided in request)
channelstringThe subscribed channel
exchangestringExchange ID
symbolstringTrading pair
tfstringTimeframe (if applicable)
bucketintBucket group (if applicable, for vd channel)

Similarly, when you unsubscribe, you receive an unsubscribed acknowledgment:

{
  "type": "unsubscribed",
  "id": "my-request-456",
  "channel": "candles",
  "exchange": "binancef",
  "symbol": "btc/usd",
  "tf": "1m"
}

After the subscribed acknowledgment, you will begin receiving data messages for the stream.

Error Responses

If a subscription fails, you will receive an error message:

{
  "type": "error",
  "code": "ERROR_CODE",
  "message": "Human-readable error description"
}

Error Codes

CodeDescription
INVALID_JSONFailed to parse message as JSON
UNKNOWN_TYPEUnknown message type (not subscribe, unsubscribe, ping, or list_subscriptions)
INVALID_PARAMSMissing required fields (channel, exchange, symbol)
INVALID_STREAMUnknown or invalid channel name
INVALID_EXCHANGEUnknown/unsupported exchange, duplicate exchange in aggregate string, or non-alphabetical aggregate ordering
INVALID_SYMBOLSymbol not found on the specified exchange
INVALID_TIMEFRAMEInvalid timeframe format, outside allowed range, or missing when required
INVALID_BUCKETInvalid or restricted bucket group
AGG_NOT_ALLOWEDMulti-exchange aggregation not allowed on your tier (Basic plans)
MAX_SUBS_EXCEEDEDConnection has reached the subscription limit
ALREADY_SUBSCRIBEDAlready subscribed to this exact stream
NOT_SUBSCRIBEDAttempting to unsubscribe from a stream you are not subscribed to

Examples

Subscribe to Candles

{
  "type": "subscribe",
  "channel": "candles",
  "exchange": "binancef",
  "symbol": "btc/usd",
  "tf": "1m"
}

Subscribe to Trades

Trades do not require a timeframe:

{
  "type": "subscribe",
  "channel": "trades",
  "exchange": "coinbase",
  "symbol": "btc/usd"
}

Subscribe to Volume Delta

Volume delta requires both timeframe and bucket:

{
  "type": "subscribe",
  "channel": "vd",
  "exchange": "bybitf",
  "symbol": "eth/usd",
  "tf": "1m",
  "bucket": 5
}

Subscribe to Open Interest

{
  "type": "subscribe",
  "channel": "oi",
  "exchange": "binancef",
  "symbol": "btc/usd",
  "tf": "1m"
}

Unsubscribe Example

{
  "type": "unsubscribe",
  "channel": "candles",
  "exchange": "binancef",
  "symbol": "btc/usd",
  "tf": "1m"
}

On this page