WebSocket API
Drip Protocol WebSocket API
The Drip Protocol WebSocket API allows real-time communication with the Orion Aggregator to receive updates on various data related to spot and futures trading. This documentation provides an overview of the available WebSocket endpoints, message formats, subscriptions, and potential errors.
WebSocket Connection
To establish a WebSocket connection to the Orion Aggregator, use the following endpoint:
wss://dev.orionprotocol.io/v1
Upon successful connection, the Aggregator sends an initial message containing a connection ID for debugging purposes.
Keep in mind that the WebSocket connection has a lifetime limit of 24 hours. If the Aggregator detects that the connection has exceeded this lifetime, it will automatically close the connection and return an error message.
Keep Alive - Ping and Pong Messages
Ping-pong messages are used by the Aggregator to keep a WebSocket connection alive. The Aggregator sends ping messages to the client on a regular basis, anticipating a pong message in return.
To keep the connection alive, the client should send the identical pong message in response to each ping message. If you do not react within the chosen pong timeout period, the Aggregator will close the connection and display the error message "WS connection has reached pong timeout."
Subscriptions
Clients can use a single WebSocket connection to subscribe to various updates from the Orion Aggregator. The Aggregator provides the following types of updates:
Address State Updates (Spot and Futures)
Aggregated Order Book Updates
Swap Info Updates
Asset Pairs Config Updates
Each type of update has its own subscription format and subscription limits.
Message Types
There are two types of messages that can be sent or received using the WebSocket API:
Server Messages: Messages sent by the aggregator.
Client Messages: Messages sent by the client (you).
Both types of messages contain the required field "T" (message type):
All the server messages contain an additional field "_" representing the aggregator's timestamp in milliseconds:
Server Messages
Initial Message
Sent by the aggregator after the connection is successfully established. This message contains the connection ID for debugging purposes.
Spot Address Updates
Represents updates of the spot address state, including balances and orders.
The "Address Updates" message can be sent without some fields:
If there are no changes in the spendable balance, the "b" field will be omitted.
If there are no changes in orders, the "o" field will be omitted.
Changes in orders can also have missing fields, as the aggregator avoids resending immutable fields if they have already been sent. Sub-orders have all their fields present.
Futures Address Updates
Represents updates of the futures address state, including balances and orders.
Order Details (Spot and Futures)
Orders details are included in the "o" array of the corresponding address update messages.
Sub Order Details
Sub order details are included in the "c" array of the corresponding order details.
Aggregated Order Book Updates
The Aggregated Order Book Updates message provides real-time updates for the order book of a specific asset pair.
Asset Pairs Config Updates (Deprecated)
This message is deprecated and used for representing updates to the asset pairs' configurations.
Single Asset Pair Info Update
This message represents an update to the configuration of a single asset pair.
Swap Updates
The Swap Updates message represents updates to a swap request and provides details about the swap execution.
Futures Trade Info Updates
Represents real-time updates for futures trade information.
Error
Indicates an error response.
Unsubscription Done
Used as a response for unsubscription.
Client Messages
Spot Address Updates Subscribe
Request for spot subscription to updates of the specified address.
Futures Address Updates Subscribe
Request for futures subscription to updates of the specified address.
Aggregated Order Book Updates Subscribe
Request for subscription to updates of the specified aggregated order book.
Asset Pairs Config Updates Subscribe
Request for subscription to updates of the asset pairs configs.
Single Asset Pair Info Update Subscribe
Request for subscription to update of the specified asset pair info.
Swap Info Subscribe
Request for subscription to updates of specified swap.
Futures Trade Info Subscribe
Request for subscription to updates of specified futures trade info.
Unsubscribe - Ending Subscriptions
To unsubscribe from specific updates, use the following format:
Pings or Pongs - Connection Health Check
To maintain a healthy connection, the Aggregator sends periodic pings, and the client responds with pongs:
Protocol - Establishing and Monitoring Connections
Connection - Initial Connection Message
After successfully establishing the connection, the Aggregator sends an initial message containing the connection ID to the client.
The connection has a limited lifetime of 24 hours. When approaching the limit, the Aggregator will inform the client with an error message:
Keep Alive - Connection Maintenance
The Aggregator ensures connection continuity by sending pings at regular intervals and expecting corresponding pongs from the client.
To maintain the connection, the client must respond with the last received ping, unchanged. Failure to do so within the specified period (pong timeout) will lead to connection closure with the error message: "WS connection has reached pong timeout."
Subscriptions - Receiving Real-Time Updates
The WebSocket API provides various subscription options for real-time updates:
Address Updates - Monitoring Account Changes
The maximum count of address subscriptions per connection is limited to 10. Subscribing to the 11th address will result in an automatic unsubscribe from the first subscription, along with the message: "The limit of 10 subscriptions of this type was reached. The subscription of 0x1FF516E5ce741085CFF86d37fc27747dF852a80a was stopped."
Upon subscription, the client will receive a snapshot of the account balances and all active and finalized orders. Subsequent updates will be delivered in real-time.
Aggregated Order Book Updates - Tracking Market Depth
The maximum count of aggregated order book subscriptions per connection is limited to 3. Subscribing to the 4th asset pair will automatically unsubscribe the first subscription, accompanied by the same message as for address subscriptions.
Swap/Futures Trade Info Updates - Observing Trading Information
The maximum count of subscriptions per connection is limited to 10. Subscribing to the 11th swap or futures trade info will automatically unsubscribe from the first subscription, with the same message as for address subscriptions.
Asset Pairs Config Updates - Retrieving Configuration Changes
There is only one subscription option for asset pairs configuration updates. Stay informed about changes to the assets and their trading configurations.
Last updated