Websocket
Last updated
Last updated
WebSocket endpoints are available for real-time data streaming and as an alternative to HTTP request sending on the Hyperliquid exchange. The WebSocket URLs by network are:
Mainnet: wss://api.hyperliquid.xyz/ws
Testnet: wss://api.hyperliquid-testnet.xyz/ws
.
To connect to the WebSocket API, you must establish a WebSocket connection to the respective URL based on your desired network. Once connected, you can start sending subscription messages to receive real-time data updates.
Example from command line:
Note: this doc uses Typescript for defining many of the message types. If you prefer to use Python, you can check out the equivalent types in the python SDK and example connection code .