npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-huobi-sdk

v1.0.36

Published

huobi REST API 和 WebSocket的 封装

Downloads

8,761

Readme

node-huobi-sdk

本SDK为huobi官方API的ts封装。集成REST API、WebScoket行情和WebScoket账户交易V2版

Install

npm install node-huobi-sdk

Usage

import HuobiSDK, { CandlestickIntervalEnum } from 'node-huobi-sdk';

const REST_URL =  'https://api.huobi.de.com';
const MARKET_WS =  'wss://api.huobi.de.com/ws';
const ACCOUNT_WS =  'wss://api.huobi.de.com/ws/v2';

// 稳定线上,需要海外服务器
// const REST_URL =  'https://api.huobi.pro';
// const MARKET_WS =  'wss://api.huobi.pro/ws';
// const ACCOUNT_WS =  'wss://api.huobi.pro/ws/v2';

const hbsdk = new HuobiSDK({
    accessKey: "access_key",
    secretKey: "secret_key",
    // errLogger: (...msg) => {
    //     errLogger.error(...msg);
    // },
    // outLogger: (...msg) => {
    //     outLogger.info(...msg);
    // },
    url:{
        rest: REST_URL,
        market_ws: MARKET_WS,
        account_ws: ACCOUNT_WS,
    }
});

// 需要先执行(只需执行一次),才能调用 钱包、下单 等接口
hbsdk.getAccountId().then(() => {
    // 查余额
    hbsdk.getAccountBalance().then((data) => {
        console.log(data.list)
    });
});


// 下单
hbsdk.order('btcusdt', 'buy-limit', 0.001, 38000);


// 行情-深度
hbsdk.subMarketDepth({symbol: SYMBOL}, (data) => console.log(data))
// 行情-k线
hbsdk.subMarketKline({symbol: SYMBOL, period: CandlestickIntervalEnum.MIN1}, (data) => console.log(data))
// 行情-交易记录
hbsdk.subMarketTrade({symbol: SYMBOL}, (data) => console.log(data))

// 需要权鉴才能ws订阅账户、订单变化
hbsdk.subAuth((data) => {
    console.log(data)
    // 订阅账户变化
    hbsdk.subAccountsUpdate({}, (data) => {
        console.log(data)
    });
});

setOptions

import HuobiSDK, { CandlestickIntervalEnum } from 'node-huobi-sdk';

const REST_URL =  'https://api.huobi.pro';
const MARKET_WS =  'wss://api.huobi.pro/ws';
const ACCOUNT_WS =  'wss://api.huobi.pro/ws/v2';

const hbsdk = new HuobiSDK();


// 异步(查数据后再去设置)
hbsdk.setOptions({
    accessKey: 'account.access_key',
    secretKey: 'account.secret_key',
    // errLogger: (...msg) => {
    //     errLogger.error(...msg);
    // },
    // outLogger: (...msg) => {
    //     outLogger.info(...msg);
    // },
    url:{
        rest: REST_URL,
        market_ws: MARKET_WS,
        account_ws: ACCOUNT_WS,
    }
});

API






### Progress

- [ ] REST
    - [x] `market`:行情
    - [x] `common`:公共
    - [x] `account`:账户
    - [x] `order`:订单
    - [ ] `margin`:借贷
    - [ ] `dw`:虚拟币提现

- [ ] WS
    - [x] `account`:账户
    - [x] `kline`:K线
    - [x] `depth`:挂单深度
    - [x] `trade detail`:交易详情
    - [ ] `market detail`:交易聚合
    - [ ] `order`: 订单


### LICENSE
MIT