API Huobi

Huobi

 

Huobi 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 attempts 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.
SubscribeMarketDepth This topic sends the latest market by price order book in snapshot mode at 1-second interval.
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.

 

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:

 

1.Whenever account balance is changed.

2.Whenever account balance or available balance is changed. (Update separately.)

3.Whenever account balance or available balance changed, it will be updated together.

 

 

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.