WebSockets
Data Engine's live data feeds can be accessed in a language agnostic manner using the Relayer via the WebSocket Protocol.
Overview
The process to access the Data Feeds is pretty straight forward using the WebSocket Protocol. Following is the necessary information for setting up a connection.
General Information
IP Limits
Do not frequently connect and disconnect the connection.
Do not start more than 100 connections in 5 minutes.
Arguments
Do not include more than 100 data feedIDs in the connection request.
Try to spread high volume data feeds like
SPOT:BTC_USDT, SPOT:ETH_USDT
across different connections to optimize.
Main Endpoint
WS
/v1/ws
This is the default endpoint to receive all the required updates from the Relayer.
Headers
Content-Type
application/json
Query Params
feedIDs
SPOT:BTC_USDT,NASDAQ:AAPL_USD
Comma-Separated List of Data Feeds
Response
Persisting Connection
Your connection is required to send a ping message after every PING_INTERVAL
to ensure that your connection is not dropped by the relayer. This will let the relayer know if any connection has become inactive or not. You can expect the Relayer to send back a PONG Frame
but do not rely your application logic on this.
Using Standard PING Frames
Using String Message
Likewise if you're to send ping messages in through a library that lacks support for sending byte frames over the WebSocket connection as seen across the WebSocket API in the current Web Standard. You can then simply proceed by sending over PING
as a string message.
Response
Subscription Response
This is the first message you receive when you set-up a WebSocket connection. This contains information about the success & failure of the data feeds you're subscribing to.
You receive a message with event type subscribe-status
whenever at least one of the requested data feedIDs is correct & available with the relayer.
You receive a subscribe-failed
message message when all of the requested data feedIDs are invalid or the connection was dropped or couldn't be set-up due to some external reason. After this message is received, the connection is closed off.
Price Response
For the supported data feeds you receive a price event that provides you with the live price at the current timestamp.
Example
To connect to the Relayer through the WS API, you need to set-up a connection to the WS URL. Once connected, you will be able to receive the requested updates.
Last updated