@bloxwap/hyperliquid documentation
@bloxwap/hyperliquid is a community-supported Hyperliquid API SDK for TypeScript and JavaScript runtimes.
Start with the core concepts, then explore the guides and reference:
Installation
Bun 1.3.3+
bun add @bloxwap/hyperliquidNode.js 22.12+
npm i @bloxwap/hyperliquidpnpm
pnpm add @bloxwap/hyperliquidYarn
yarn add @bloxwap/hyperliquidReact Native 0.86+
npm i @bloxwap/hyperliquidThe fastAssetCtxs subscription additionally needs DecompressionStream, Web Streams, and TextDecoder, none of which
Hermes provides:
npm i text-encoding-polyfill web-streams-polyfill compression-streams-polyfillimport "text-encoding-polyfill";
import "web-streams-polyfill/polyfill";
import "compression-streams-polyfill";On React Native < 0.86, the global Event and EventTarget are missing:
npm i event-target-shimimport { Event, EventTarget } from "event-target-shim";
if (!globalThis.EventTarget) globalThis.EventTarget = EventTarget;
if (!globalThis.Event) globalThis.Event = Event;On React Native < 0.84, the native URL is incomplete:
npm i react-native-url-polyfillimport "react-native-url-polyfill/auto";Import every polyfill before @bloxwap/hyperliquid, such as at the top of index.js.
Quick start
Read market data
Use InfoClient to read market data, account state, and order books. See the Info endpoint
for all client behavior.
import { HttpTransport, InfoClient } from "@bloxwap/hyperliquid";
const transport = new HttpTransport();
const client = new InfoClient({ transport });
const mids = await client.allMids();Trade
Use ExchangeClient to place orders, transfer funds, and manage accounts. See the
Exchange endpoint before using a funded wallet.
import { ExchangeClient, HttpTransport } from "@bloxwap/hyperliquid";
import { privateKeyToAccount } from "viem/accounts";
const wallet = privateKeyToAccount("0x...");
const transport = new HttpTransport();
const client = new ExchangeClient({ transport, wallet });
await client.order({
orders: [{
a: 0,
b: true,
p: "50000",
s: "0.01",
r: false,
t: { limit: { tif: "Gtc" } },
}],
grouping: "na",
});Subscribe
Use SubscriptionClient to receive real-time updates. See
WebSocket subscriptions for subscription lifecycle details.
import { SubscriptionClient, WebSocketTransport } from "@bloxwap/hyperliquid";
const transport = new WebSocketTransport();
const client = new SubscriptionClient({ transport });
await client.allMids((data) => {
console.log(data.mids);
});Explore
Use ExplorerClient to look up blocks, transactions, and addresses. See the
Explorer endpoint for the available methods.
import { ExplorerClient, HttpTransport } from "@bloxwap/hyperliquid";
const transport = new HttpTransport();
const client = new ExplorerClient({ transport });
const block = await client.blockDetails({ height: 123 });Versioning
This SDK follows Semantic Versioning. Until 1.0.0, breaking changes bump the minor version and
everything else bumps the patch, following the
caret-range convention.
The exception is request, response, and event types that mirror the Hyperliquid API. The API is unversioned and always serves its latest shape, so changes to these types ship in patch releases even when breaking: the break comes from Hyperliquid, not the SDK.
For places where the official Hyperliquid documentation and the live API currently disagree, see Known documentation drift.