API Huobi

Huobi (HTX)

Huobi (now rebranded as HTX) is an international multi-language cryptocurrency exchange.

Configuration

If you want to subscribe to the private account updates, you need to create an API Key in your Huobi Account. Once created, set the API Key and Secret in the Huobi API Client

If the ApiKey is not empty, the client will attempt to connect to the private websocket server, so only the private methods will be available. If the ApiKey is empty, the client will connect to the public websocket server and only the public methods will be available. If you need to subscribe to public and private methods, you need 2 connections.

Public Methods

You can subscribe to the following public channels (api key is not required)

Method Description
SubscribeKLine This topic sends a new candlestick whenever it is available. Supported periods: 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon, 1week, 1year.
SubscribeMarketDepth This topic sends the latest market by price order book in snapshot mode at 1-second interval. Supported depth aggregation levels: step0 through step15.
SubscribeTradeDetail This topic sends the latest completed trades. It updates in tick by tick mode.
SubscribeMarketDetail

This topic sends the latest market stats with 24h summary. It updates in snapshot mode, in frequency of no more than 10 times per second

SubscribeBBO User can receive BBO (Best Bid/Offer) update in tick by tick mode.
SubscribeMarketTicker

Retrieve the market ticker,data is pushed every 100ms.

SubscribeMarketByPrice User could subscribe to this channel to receive refresh update of Market By Price order book. The update interval is around 100ms. Supported levels: 5, 10, 20, 150, 400.

Futures Public Methods

The following methods are available for the Futures API client (TsgcWS_API_Huobi_Fut) in addition to all the public methods above.

Method Description
SubscribeIncrementalMarketDepth Subscribe to incremental market depth updates with configurable size and data type (snapshot or incremental).
SubscribePremiumIndexKLine Subscribe to premium index kline/candlestick data for futures contracts.
SubscribeEstimatedRateKLine Subscribe to estimated funding rate kline/candlestick data for futures contracts.
SubscribeBasisData Subscribe to basis data (spot-futures price spread). Supports different basis price types: open, close, high, low.
SubscribeMarkPriceKLine Subscribe to mark price kline/candlestick data for futures contracts.
SubscribeLiquidationOrders Subscribe to public liquidation order feed for a given contract. No authentication required.
SubscribeFundingRate Subscribe to public funding rate updates for a given contract. No authentication required.
SubscribeContractInfo Subscribe to contract parameter changes (e.g. contract listings, delistings, parameter adjustments).

Private Methods

You can subscribe to the following private channels (an api key is required). If the credentials are not correct, the connection will be closed automatically.

Method Description
SubscribeOrderUpdates

An order update can be triggered by any of following:


- Conditional order triggering failure (eventType=trigger)
- Conditional order cancellation before trigger (eventType=deletion)
- Order creation (eventType=creation)
- Order matching (eventType=trade)
- Order cancellation (eventType=cancellation)

SubscribeTradeClearing Only update when order is in transaction or cancellation. Order transaction update is in tick by tick mode, which means, if a taker's order matches with multiple maker's orders, the simultaneous multiple trades will be disseminated one by one. But the update sequence of the multiple trades, may not be exactly the same as the sequence of the transactions made. Also, if an order is auto cancelled immediately just after its partial fills, for example a typical IOC order, this channel would possibly disseminate the cancellation update first prior to the trade.
SubscribeAccountChange

Upon subscription field value specified, the update can be triggered by either of following events. The aMode parameter controls the update behavior:

Mode 0: Only update when account balance is changed.

Mode 1: Update when either account balance or available balance is changed (separate updates).

Mode 2: Update when account balance or available balance is changed (combined update).

Events

OnHuobiSubscribed: event called after a successful subscription.

OnHuobiUnSubscribed: event called after a successful unsubscription.

OnHuobiUpdate: every time there is an update in data (kline, market depth...) this event is called.

OnHuobiError: if there is an error in Huobi API, this event will provide information about error.