@bloxwap/hyperliquid

中文文档
0.7.0发布于 2026/10/24MITTypeScriptES Module构建来源已验证近 30 天下载 2638

Blazing fast TypeScript Hyperliquid SDK.

原始使用文档
文档目录11 节
  1. Features
  2. Documentation
  3. Installation
  4. Bun 1.3.3+
  5. Node.js 22.12+ / React Native 0.86+
  6. pnpm
  7. Yarn
  8. Quick Example
  9. Read
  10. Trade
  11. Subscribe

Hyperliquid
Blazing fast typescript Hyperliquid SDK

npm version npm downloads Codecov coverage Bundle size

Features

  • Typed: Source code is 100% TypeScript.
  • Tested: Good code coverage and type relevance.
  • Minimal dependencies: A few small trusted dependencies.
  • Cross-Environment Support: Compatible with all major JS runtimes.
  • Integratable: Easy to use with viem accounts — local (private key) or JSON-RPC (browser wallet).

Documentation

Browse the SDK documentation for installation, clients, transports, signing, utilities, and guides.

The documentation uses Fumadocs and is hosted on GitHub Pages. Its Markdown source lives in apps/docs/content/docs/ in the repository.

Installation

Bun 1.3.3+

bun add @bloxwap/hyperliquid

Node.js 22.12+ / React Native 0.86+

npm i @bloxwap/hyperliquid

pnpm

pnpm add @bloxwap/hyperliquid

Yarn

yarn add @bloxwap/hyperliquid

React Native needs polyfills for the fastAssetCtxs subscription and for versions below 0.86 — see the documentation.

Quick Example

Read

// 1. Import module
import { HttpTransport, InfoClient } from "@bloxwap/hyperliquid";

// 2. Set up client with transport
const transport = new HttpTransport();
const info = new InfoClient({ transport });

// 3. Query data

// Retrieve mids for all coins
const mids = await info.allMids();

// Retrieve a user's open orders
const openOrders = await info.openOrders({ user: "0x..." });

// L2 book snapshot
const book = await info.l2Book({ coin: "BTC" });

Trade

// 1. Import modules
import { ExchangeClient, HttpTransport } from "@bloxwap/hyperliquid";
import { privateKeyToAccount } from "viem/accounts";

// 2. Set up client with wallet and transport
const wallet = privateKeyToAccount("0x...");

const transport = new HttpTransport();
const exchange = new ExchangeClient({ transport, wallet });

// 3. Execute an action

// Place an order
const result = await exchange.order({
  orders: [{
    a: 0,
    b: true,
    p: "95000",
    s: "0.01",
    r: false,
    t: { limit: { tif: "Gtc" } },
  }],
  grouping: "na",
});

// Update leverage
await exchange.updateLeverage({ asset: 0, isCross: true, leverage: 5 });

// Initiate a withdrawal request
await exchange.withdraw3({ destination: "0x...", amount: "1" });

For low-latency bots, pass the raw private key string as wallet: the client then signs with WASM secp256k1 by default, with a pure-JS fallback where WASM cannot load (~274 to ~104 µs per order on Node 24, ~155 to ~102 µs on Bun 1.4). Install the optional hash-wasm package for ambient keccak acceleration. Trusted callers can also pass { skipValidation: true }. See the low-latency recipe.

Subscribe

// 1. Import module
import { SubscriptionClient, WebSocketTransport } from "@bloxwap/hyperliquid";

// 2. Set up client with transport
const transport = new WebSocketTransport();
const subs = new SubscriptionClient({ transport });

// 3. Subscribe to events

// Subscribe to mids for all coins
await subs.allMids((data) => {
  console.log(data);
});

// Subscribe to user's open orders
await subs.openOrders({ user: "0x..." }, (data) => {
  console.log(data);
});

// Subscribe to L2 book snapshot
await subs.l2Book({ coin: "ETH" }, (data) => {
  console.log(data);
});

[!WARNING]

  • Never hardcode private keys in source or commit them to git. Load them from environment variables or a secret store (Bun auto-loads a local .env, which is gitignored in this repo).
  • For trading bots, prefer a Hyperliquid agent wallet (API wallet) over the master account key: an agent key can trade but cannot withdraw, and it can be revoked without rotating the master key.
  • See Signing for how wallets, signatures, and nonces work.

版本与发布记录

@bloxwap/hyperliquid 共发布 14 个版本,首次发布于 2026/07/27;过去 12 个月发布了 14 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.0latest2026/10/2415 天前
0.6.02026/10/1227 天前
0.5.02026/09/261 个月前
0.4.02026/09/201 个月前
0.3.02026/08/252 个月前
0.2.12026/08/043 个月前

关于 @bloxwap/hyperliquid 的常见问题

@bloxwap/hyperliquid 是什么?

Blazing fast TypeScript Hyperliquid SDK.

如何安装 @bloxwap/hyperliquid?

在项目目录运行 npm install @bloxwap/hyperliquid,或使用 pnpm add / yarn add / bun add。

@bloxwap/hyperliquid 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bloxwap/hyperliquid 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bloxwap/hyperliquid 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bloxwap/hyperliquid 可以商用吗?

@bloxwap/hyperliquid 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bloxwap/hyperliquid 的下载量有多少?

根据 npm 官方下载统计,@bloxwap/hyperliquid 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,638 次,日均约 88 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bloxwap/hyperliquid 还在维护吗?

最新版本 0.7.0 发布于 2026/10/24(15 天前);至今共发布 14 个版本,其中过去 12 个月发布了 14 个;首次发布于 2026/07/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。