Exchange WebSocket Overview
TIP
ws-direct
is your primary connection, we recommend using ws-feed
as a failover.INFO
production = wss://ws-feed.exchange.coinbase.com
sandbox = wss://ws-feed-public.sandbox.exchange.coinbase.com
production = wss://ws-direct.exchange.coinbase.com
sandbox = wss://ws-direct.sandbox.exchange.coinbase.com
Protocol
type
attribute that can be used to handle the message appropriately.TIP
Subscribe
subscribe
message to the server indicating which channels and products to receive. This message is mandatory—you are disconnected if no subscribe
has been received within 5 seconds.CAUTION
subscribe
message or you are disconnected in 5 seconds.// Request
// Subscribe to ETH-USD and ETH-EUR with the level2, heartbeat and ticker channels,
// plus receive the ticker entries for ETH-BTC and ETH-USD
{
"type": "subscribe",
"product_ids": ["ETH-USD", "ETH-EUR"],
"channels": [
"level2",
"heartbeat",
{
"name": "ticker",
"product_ids": ["ETH-BTC", "ETH-USD"]
}
]
}
subscriptions
message as a response to an subscribe
message.Unsubscribe
unsubscribe
message. The structure is equivalent to subscribe
messages.// Request
{
"type": "unsubscribe",
"channels": ["heartbeat"]
}
subscriptions
message as a response to an unsubscribe
message.Specifying Product IDs
// Request
{
"type": "unsubscribe",
"product_ids": ["ETH-USD", "ETH-EUR"],
"channels": ["ticker"]
}
Subscriptions Message
subscriptions
message is sent in response to both subscribe and unsubscribe messages.subscribe
message, the subscriptions
message lists all channels you are subscribed to. Subsequent subscribe messages add to the list of subscriptions. If you subscribed to a channel without being authenticated, you will remain in the unauthenticated channel.// Response
{
"type": "subscriptions",
"channels": [
{
"name": "level2",
"product_ids": ["ETH-USD", "ETH-EUR"]
},
{
"name": "heartbeat",
"product_ids": ["ETH-USD", "ETH-EUR"]
},
{
"name": "ticker",
"product_ids": ["ETH-USD", "ETH-EUR", "ETH-BTC"]
}
]
}
Websocket Compression Extension
Sequence Numbers
CAUTION
TIP
End-to-end Example
Modified at 2025-03-24 09:31:51