node-api-huobi
WARNING: This package is still early beta! Expect breaking changes until this sees a major release.
Non-official implementation of Huobi's API's. Developed for personal use.
For support on using the API's or development issues, please refer to the official API documentation. For questions regarding this package, please consult the code first.
PUBLIC API
const huobi=require('node-api-huobi');
const publicAPI=new huobi.publicApi();
Reference Data
API | DESCRIPTION |
---|---|
getSystemStatus | Not implemented |
getMarketStatus | https://huobiapi.github.io/docs/spot/v1/en/#get-market-status |
getSymbols | https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v2 |
getCurrencies | https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-currencies-v2 |
getCurrencySettings | https://huobiapi.github.io/docs/spot/v1/en/#get-currencys-settings |
getSymbolSettings | https://huobiapi.github.io/docs/spot/v1/en/#get-symbols-setting |
getMarketSettings | https://huobiapi.github.io/docs/spot/v1/en/#get-market-symbols-setting |
getChainsInfo | https://huobiapi.github.io/docs/spot/v1/en/#get-chains-information |
getChainCurrencies | https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains |
getTimestamp | https://huobiapi.github.io/docs/spot/v1/en/#get-current-timestamp |
Market Data
API | DESCRIPTION |
---|---|
getKlines | https://huobiapi.github.io/docs/spot/v1/en/#get-klines-candles |
getTicker | https://huobiapi.github.io/docs/spot/v1/en/#get-latest-aggregated-ticker |
getAllTickers | https://huobiapi.github.io/docs/spot/v1/en/#get-latest-tickers-for-all-pairs |
getMarketDepth | https://huobiapi.github.io/docs/spot/v1/en/#get-market-depth |
getLastTrade | https://huobiapi.github.io/docs/spot/v1/en/#get-the-last-trade |
getRecentTrades | https://huobiapi.github.io/docs/spot/v1/en/#get-the-most-recent-trades |
getMarketSummary | https://huobiapi.github.io/docs/spot/v1/en/#get-the-last-24h-market-summary |
getNetAssetValue | https://huobiapi.github.io/docs/spot/v1/en/#get-real-time-nav |
PRIVATE API
const huobi=require('node-api-huobi');
const auth = {
apikey: 'MY_API_KEY',
secret: 'MY_API_SECRET'
};
const privateAPI=new huobi.privateApi(auth);
Account
API | DESCRIPTION |
---|---|
getAccounts | https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user |
getBalance | https://huobiapi.github.io/docs/spot/v1/en/#get-account-balance-of-a-specific-account |
getPlatformValue | https://huobiapi.github.io/docs/spot/v1/en/#get-the-total-valuation-of-platform-assets |
getAssetValuation | https://huobiapi.github.io/docs/spot/v1/en/#get-asset-valuation |
transferAsset | https://huobiapi.github.io/docs/spot/v1/en/#asset-transfer |
transferSubAccountAsset | https://huobiapi.github.io/docs/spot/v1/en/#asset-transfer |
getAccountHistory | https://huobiapi.github.io/docs/spot/v1/en/#get-account-history |
getAccountLedger | https://huobiapi.github.io/docs/spot/v1/en/#get-account-ledger |
transferSpotFuture | https://huobiapi.github.io/docs/spot/v1/en/#transfer-fund-between-spot-account-and-future-contract-account |
getPointBalance | https://huobiapi.github.io/docs/spot/v1/en/#get-point-balance |
transferPoints | https://huobiapi.github.io/docs/spot/v1/en/#point-transfer |
Wallet
API | DESCRIPTION |
---|---|
getDepositAddress | https://huobiapi.github.io/docs/spot/v1/en/#query-deposit-address |
getWithdrawQuota | https://huobiapi.github.io/docs/spot/v1/en/#query-withdraw-quota |
getWithdrawAddress | https://huobiapi.github.io/docs/spot/v1/en/#query-withdraw-address |
createWithdrawRequest | https://huobiapi.github.io/docs/spot/v1/en/#create-a-withdraw-request |
getWithdrawal | https://huobiapi.github.io/docs/spot/v1/en/#query-withdrawal-order-by-client-order-id |
cancelWithdrawal | https://huobiapi.github.io/docs/spot/v1/en/#cancel-a-withdraw-request |
getWithdrawalsDeposits | https://huobiapi.github.io/docs/spot/v1/en/#search-for-existed-withdraws-and-deposits |
Sub-User
Trading
Conditional Order
API | DESCRIPTION |
---|---|
placeConditionalOrder | https://huobiapi.github.io/docs/spot/v1/en/#place-a-conditional-order |
cancelConditionalOrder | https://huobiapi.github.io/docs/spot/v1/en/#cancel-conditional-orders-before-triggering |
getConditionalOrders | https://huobiapi.github.io/docs/spot/v1/en/#query-open-conditional-orders-before-triggering |
searchConditionalOrderHistory | https://huobiapi.github.io/docs/spot/v1/en/#query-conditional-order-history |
searchConditionalOrder | https://huobiapi.github.io/docs/spot/v1/en/#query-a-specific-conditional-order |
Margin
Stable Coin Exchange
API | DESCRIPTION |
---|---|
getExchangeRate | https://huobiapi.github.io/docs/spot/v1/en/#stable-coin-exchange |
exchangeCoin | https://huobiapi.github.io/docs/spot/v1/en/#exchange-stable-coin |
Exchange Traded Products (ETP)
WEBSOCKET API
const huobi=require('node-api-huobi');
const auth = {
apikey: 'MY_API_KEY',
secret: 'MY_API_SECRET'
};
const marketAPI=new huobi.sockets.marketApi();
const mbpAPI=new huobi.sockets.MBPApi();
const tradingAPI=new huobi.sockets.tradingApi(auth);
tradingAPI.setHandler('orders', (symbol,method,data,option) => { updateOrder(symbol,method,data); });
tradingAPI.socket._ws.on('authenticated', async () => { // For market API's: initialized
const res=await tradingAPI.subscribeOrderUpdates();
});
tradingAPI.socket._ws.on('closed', async () => {
// do something, like clean-up and reconnect
});
function updateOrder(symbol,method,data) {
// do something
};
MARKET DATA
const marketAPI=new huobi.sockets.marketApi();
API | HANDLER | DESCRIPTION |
---|---|---|
subscribeCandles unsubscribeCandles getCandle | market.kline | https://huobiapi.github.io/docs/spot/v1/en/#market-candlestick |
subscribeTickers unsubscribeTickers getTicker | market.ticker | https://huobiapi.github.io/docs/spot/v1/en/#market-ticker |
subscribeMarketDepth unsubscribeMarketDepth getMarketDepth | market.depth | https://huobiapi.github.io/docs/spot/v1/en/#market-depth |
subscribeBests unsubscribeBests getBest | market.bbo | https://huobiapi.github.io/docs/spot/v1/en/#best-bid-offer |
subscribeTrades unsubscribeTrades getTrades | market.trade | https://huobiapi.github.io/docs/spot/v1/en/#trade-detail |
subscribeStats unsubscribeStats getStats | market.detail | https://huobiapi.github.io/docs/spot/v1/en/#market-details |
subscribeETP unsubscribeETP getETP | market.etp | https://huobiapi.github.io/docs/spot/v1/en/#subscribe-etp-real-time-nav |
MARKET BY PRICE (MBP) DATA
const mbpAPI=new huobi.sockets.MBPApi();
API | HANDLER | DESCRIPTION |
---|---|---|
subscribeMBPIncremetal unsubscribeMBPIncremetal getMBPIncremetal | market.mbp | https://huobiapi.github.io/docs/spot/v1/en/#market-by-price-incremental-update |
subscribeMBPRefresh unsubscribeMBPRefresh getMBPRefresh | market.mbp.refresh | https://huobiapi.github.io/docs/spot/v1/en/#market-by-price-refresh-update |
ACCOUNT AND ORDER
const tradingAPI=new huobi.sockets.tradingApi();
API | HANDLER | DESCRIPTION |
---|---|---|
subscribeOrderUpdates unsubscribeOrderUpdates | orders | https://huobiapi.github.io/docs/spot/v1/en/#subscribe-order-updates |
subscribeTradeClearing unsubscribeTradeClearing | trade.clearing | https://huobiapi.github.io/docs/spot/v1/en/#subscribe-trade-details-amp-order-cancellation-post-clearing |
subscribeAccountChange unsubscribeAccountChange | accounts.update | https://huobiapi.github.io/docs/spot/v1/en/#subscribe-account-change |