The WebSocket API provides a high-performance, low-latency communication channel for real-time trading data and order execution. This section introduces the key technologies used in the API: WebSockets and Google Protocol Buffers (Protobuf).
WebSockets establish a persistent, full-duplex connection between the client and server, allowing for continuous bi-directional message exchange. This ensures minimal latency, making it ideal for market data feeds and order updates.
Key Advantages:
The API utilizes Protobuf for efficient, compact, and high-speed message serialization. Unlike JSON or XML, Protobuf messages are smaller and faster to parse, making them well-suited for high-frequency trading applications.
Why Protobuf?
The API follows a structured messaging approach:
All messages are wrapped within a top-level client or server message envelope. This structure ensures extensibility and consistency across different message types.
Example Envelope: ``` message ClientMessage {
oneof payload { SubscribeRequest subscribe = 1; OrderRequest order = 2; }
}
message ServerMessage {
oneof payload { MarketUpdate market_data = 1; OrderResponse order_response = 2; }
} ```
This design enables efficient message parsing while maintaining flexibility.
Continue to the [Connecting and Authenticating](developers:websocket:connecting) section to learn how to establish a WebSocket connection and authenticate your session.