/huobi-client-websocket

C# client for Huobi websocket API

Primary LanguageC#Apache License 2.0Apache-2.0

Logo

Huobi websocket API client Build status NuGet version Nuget download

This is a C# implementation of the Huobi websocket API found here:

https://huobiapi.github.io/docs/spot/v1/en/

Releases and breaking changes

License:

Apache License 2.0

Features

  • installation via NuGet (Huobi.Client.Websocket)
  • public and authenticated API
  • targeting .NET Standard 2.0 (.NET Core, Windows/Linux/MacOS compatible)
  • reactive extensions (Rx.NET)

Usage

var exitEvent = new ManualResetEvent(false);
var url = HuobiConstants.ApiWebsocketUrl;

using var client = HuobiWebsocketClientsFactory.CreateMarketClient(url);
client.Streams.TradeDetailUpdateStream.Subscribe(
    msg =>
    {
        for (var i = 0; i < msg.Tick?.Data.Length; ++i)
        {
            var item = msg.Tick.Data[i];

            Console.WriteLine(
                $"Market trade detail update {msg.Topic}"
              + $" | [item {i}: amount={item.Amount} price={item.Price} direction={item.Direction}]");
        }
    });

var subscribeRequest = new MarketTradeDetailSubscribeRequest("id1", "btcusdt");
client.Send(subscribeRequest);

await client.Start();

exitEvent.WaitOne(TimeSpan.FromSeconds(30));

There are three types of clients where each connects to different Huobi API to get related data:

  • Market client (src) - Market data from wss://api.huobi.pro/ws
  • MarketByPrice client (src) - MBP incremental data from wss://api.huobi.pro/feed
  • Account client (src) - Assets and Order data from wss://api.huobi.pro/ws/v2

More usage examples:

  • integration tests (link)
    • you can setup which client to run by registration to DI container here

API coverage

PUBLIC Covered
Ping-Pong
Subscribe
Unsubscribe
Market candlestick
Market depth
Market by price
Market best bid/offer
Market trade detail
Market details
Errors
AUTHENTICATED Covered
Ping-Pong
Authentication
Order updates
Trade details
Account updates

Pull Requests are welcome!

Other websocket libraries


Extensions
All order books together, etc.

Bitmex

Bitfinex

Binance

Coinbase Pro