WebSocket Endpoint URL
wss://ws-feed.prime.coinbase.comRate Limits
Real-time market data updates provide the fastest insight into order flow and trades. You are responsible for reading the message stream and using the message relevant for your needs—this can include building real-time order books or tracking real-time trades.Specs
The WebSocket feed is publicly available. Connection requests to it are rate-limited at 750 every 10 seconds per IP. Note: All Prime infrastructure is located in AWS US-east 1 region. For optimal performance and latency, its recommended that client deploy their applications in AWS US-EAST 1.
Errors
An error message displays when the client is actively disconnected for any of these reasons:- The client has too many backed up messages (
ErrSlowConsume). - The client is sending too many messages (
ErrSlowRead). - The message size is too large (
Message too big) - There are intermittent network issues.
Protocol
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.
Error messages:
Most failure cases trigger an error message—specifically, a message with the type "error". This can be helpful when implementing a client or debugging issues.
Subscribing
To begin receiving feed messages, you must send a signedsubscribe 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.
subscribe message is received the server responds with a subscriptions message that lists all channels you are subscribed to. Subsequent subscribe messages add to the list of subscriptions.
Unsubscribing
To unsubscribe from channel/product pairs, send anunsubscribe message. The structure is equivalent to subscribe messages.
unsubscribe message you will receive a subscriptions message:
Signing Messages
You must authenticate yourself when subscribing to any of the Prime WebSocket channels. Construct a payload schema for all channels with the following list of properties and valid values:type: “subscribe” or “unsubscribe”channel: WebSocket channel to subscribe toaccess_key: Public API keyapi_key_id: Service account IDtimestamp: ISO 8601 for requests (seconds since the epoch); or Epoch for creating signatures. Valid ISO 8601 format:%Y-%M-%DT%H:%M:%SZ, for example,2022-02-19T20:05:22Z.passphrase: Your API passphrasesignature: SHA256 HMAC signature using the prehash string and API secret keyportfolio_id/order_id: The portfolio or order ID (depending on which feed you’re subscribing to.portfolio_idis required fororderschannel.)product_ids: Comma-separated list of products to subscribe to (["BTC-USD"])
signature field is generated by creating a SHA256 HMAC by signing your API Secret key with a prehash string. The final prehash payload is generated by creating a concatenated string of channelName + accessKey + svcAccountId + timestamp + portfolioId + products (where + represents string concatenation).
Apply a SHA256 HMAC using your secret key on this prehash payload, and then base64-encode it as your final payload within your request. Pass the output of this SHA256 HMAC to the signature field in each request message. See the examples of generating this signature below.
For requests that subscribe to multiple products (e.g.,
product_ids: ["BTC-USD", "ETH-USD"]), the product_ids string in the prehash must be formatted as follows: BTC-USDETH-USD.