This page outlines all of the general Websocket API endpoints available via implementations from IBinanceWebSocketClient
.
All endpoints are access the same way, with the only difference being the data returned, outside of arguments provided.
Guid ConnectToKlineWebSocket(string symbol, KlineInterval interval, BinanceWebSocketMessageHandler<BinanceKlineData> messageEventHandler);
Guid ConnectToDepthWebSocket(string symbol, BinanceWebSocketMessageHandler<BinanceDepthData> messageEventHandler);
Guid ConnectToTradesWebSocket(string symbol, BinanceWebSocketMessageHandler<BinanceAggregateTradeData> messageEventHandler);
Task<Guid> ConnectToUserDataWebSocket(UserDataWebSocketMessages userDataMessageHandlers);
Sample Usage - Disposable
using (var binanceWebSocketClient = new DisposableBinanceWebSocketClient(binanceClient))
{
binanceWebSocketClient.ConnectToTradesWebSocket("ETHBTC", data =>
{
System.Console.WriteLine($"KlineCall: {JsonConvert.SerializeObject(data)}");
});
}
Sample Usage - Manual
var binanceWebSocketClient = new InstanceBinanceWebSocketClient(binanceClient))
binanceWebSocketClient.ConnectToTradesWebSocket("ETHBTC", data =>
{
System.Console.WriteLine($"KlineCall: {JsonConvert.SerializeObject(data)}");
});
When opening WebSockets
you are provided with a unique Guid, which can be used to close individual instances through this method