Gemini Crypto Exchange Logo
Overview

Sequence Numbers

So you can easily ensure that you are receiving all of your WebSocket messages in the expected order without any gaps, events and heartbeats contain a special sequence number.

  1. WebSocket connection is established
  2. Optional: subscription acknowledgement, such as Order Events: Subscription Acknowledgement
  3. Your subscription begins - you receive your first event with socket_sequence set to a value of 0
  4. For all further messages, each message - whether a heartbeat or an event - should increase this sequence number by one.
    • If you see a gap in this sequence number, then you should disconnect and reconnect.

Note:

  • Each time you reconnect, the sequence number resets to zero.
  • If you have multiple WebSocket connections, each will have a separate sequence number beginning with zero - make sure to keep track of each sequence number separately!