- Market Data is our traditional feed that provides updates for both orders and trades. Most channels are now available without authentication.
- User Order Data provides updates for the orders of the user.
Market Data Endpoint:
User Order Data Endpoint:
wss://advanced-trade-ws.coinbase.comUser Order Data Endpoint:
wss://advanced-trade-ws-user.coinbase.comProtocol
The WebSocket feed uses a bidirectional protocol that encodes all messages as JSON objects. All messages have atype attribute that can be used to handle the message appropriately.
Sending Messages with CDP Keys
Subscribing
To begin receiving feed messages, you must send asubscribe message to the server indicating which channel and products to receive. This message is mandatory and you are disconnected if no subscribe has been received within 5 seconds.
You can subscribe to multiple channels but you must send a unique subscription message for each channel.
channel name and jwt:
-
channelname as a string. You can only subscribe to one channel per subscription message. -
jwtcan be generated by running one of the code snippets provided in the WebSocket Authentication page. Remember that you must generate a different JWT for each websocket message sent, since the JWTs will expire after 2 minutes.
Unsubscribing
To unsubscribe from a channel/product pair, send anunsubscribe message. The structure is the same as subscribe message. You can only unsubscribe from one channel per subscription message. You can also unsubscribe from a channel entirely by providing no product IDs.
subscriptions message as a response to an unsubscribe message.
Websocket Code Samples
Use the code samples to subscribe to one or more Advanced Trade WebSocket channels using CDP API Keys.- JavaScript
- Python