Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.63 KB

WEBSOCKET-API.md

File metadata and controls

47 lines (38 loc) · 1.63 KB

WebSocket API

This page outlines all of the general Websocket API endpoints available via implementations from IBinanceWebSocketClient.

WebSocket Endpoints

Binance Documentation

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)}");
});

Additional API

CloseWebSocketInstance(Guid id, bool fromError = false): void

When opening WebSockets you are provided with a unique Guid, which can be used to close individual instances through this method