Node.js & JavaScript SDK for Hyperliquid REST APIs & WebSockets
Professional Node.js, JavaScript & TypeScript SDK for the Hyperliquid REST APIs, WebSocket APIs & WebSocket Events.
Take a look at our dedicated HyperLiquid API quickstart guides for major frameworks and JavaScript runtimes.
- Complete integration with all HyperLiquid REST APIs & WebSockets, including the WebSocket API.
- Actively maintained with a modern, promise-driven interface.
- TypeScript support with thorough type declarations for API requests and responses, including the WebSocket API.
- JavaScript support. TypeScript is not required, but is definitely recommended.
- Thorough automated tests covering requests, signing, WebSockets, types, and package consumers.
- Proxy support via Axios integration.
- Robust WebSocket consumer integration with configurable heartbeats & automatic reconnect then resubscribe workflows.
- Event-driven messaging.
- Smart WebSocket persistence.
- Automatically detect silent WebSocket disconnections through timed heartbeats.
- Restore cached subscriptions after reconnecting.
- Emit a
reconnected event when a dropped connection is restored.
- WebSocket API integration, with two promise-driven approaches:
- Import
WebsocketAPIClient and use it like the REST API client. Call typed methods and await their responses.
- Use
sendWSAPIRequest(...) directly when you need raw WebSocket POST access.
- The method connects requests to responses and returns a promise.
- One
RestClient for public market data, account information, trading, transfers, staking, vaults, subaccounts, deployer actions, multisig, validators, and borrow/lend.
- MessagePack L1 signing and user-signed EIP-712 actions.
- Private keys and portable
signTypedData signers.
- CEX-style helpers for market orders, limit orders, market closes, balances, and account summaries.
- Perpetual, spot, HIP-3, and outcome asset resolution using official identifiers and metadata-derived aliases.
- Dual ESM and CommonJS output.
- Browser-safe public REST API calls and public WebSocket subscriptions.
- Active community support & collaboration in telegram: Node.js Algo Traders.
Table of Contents
Overview
REST API Examples
WebSocket Integration & Examples
Additional Features
Contributing
Installation
npm install @siebly/hyperliquid-api
Node.js 22 or newer is supported.
Frameworks & Quickstart Guides
Our complete Hyperliquid SDK supports all the major JavaScript runtimes. For maximum convenience, we've included guides to quickly get you started with the most popular runtimes. If you're not sure how to use this SDK with a runtime or framework not listed here, feel free to open an issue on GitHub.
Refer to runtime compatibility for a complete list of runtimes that we've actively tested, including setup guides.
Documentation
The Hyperliquid SDK documentation page covers complete guidance on installation, client setup, public APIs (e.g. market data), private APIs (e.g. trading, order management), and WebSockets (subscriptions, WebSocket API, authentication, etc).
Hyperliquid exchange API reference
Request and response types are exported from the package root. Every documented Info and Exchange operation has a corresponding RestClient method. Public lookup methods use get... names based on the information they return instead of exposing Hyperliquid's internal request type names. See the examples directory for REST API, WebSocket, and WebSocket API samples.
Exchange methods share one response wrapper: ExchangeResponse for acknowledgements, or ExchangeResponse<T> when the response contains data, such as ExchangeResponse<OrderResponseData> for orders and ExchangeResponse<string> for a new vault or subaccount address. For an order result, check order.status === 'ok' before reading order.response.data. Raw Exchange methods use ExchangeResponse<unknown> because the response depends on the submitted action. The same types apply to RestClient and WebsocketAPIClient.
Issues & Discussion
- Issues? Check the issues tab.
- Discuss & collaborate with other node devs? Join our Node.js Algo Traders engineering community on telegram.
- Follow our announcement channel for real-time updates on X/Twitter
Related Projects
Check out our JavaScript/TypeScript/Node.js SDKs & Projects:
- Visit our website: https://Siebly.io
- Try our REST API & WebSocket SDKs published on npmjs:
- Try my misc utilities:
- Check out my examples:
REST API
Public info methods do not need credentials:
import { RestClient } from '@siebly/hyperliquid-api';
const client = new RestClient();
const mids = await client.getAllMids();
const book = await client.getOrderBook({
coin: 'BTC',
nSigFigs: 5,
});
const perpSummary = await client.getPerpAccountSummary({
user: '0x1234567890123456789012345678901234567890',
});
const spotBalances = await client.getSpotBalances({
user: '0x1234567890123456789012345678901234567890',
});
if (book) {
console.log(book.levels[0][0]);
}
Use testnet: true for the testnet API:
const client = new RestClient({ testnet: true });
Signed methods accept a private key on a trusted backend: