SDK guide
JavaScript
REST API + WebSocket

Hyperliquid JavaScript SDK

Use @siebly/hyperliquid-api to read Hyperliquid market data, manage orders, and consume streams from Node.js. JavaScript and TypeScript use the same clients; request and response types are included.

Unpublished previewGitHubREADME

Choose a client

RestClient
Market data, account state, orders, transfers, staking, vaults, subaccounts, HIP-3, and other Info and Exchange operations
WebsocketClient
Public market data and address-scoped account subscriptions
WebsocketAPIClient
Awaitable Info and signed Exchange requests over the WebSocket POST protocol

Make a first public request

This SDK is an unpublished preview and requires repository access. Contact Siebly for preview access. If you already have access, use Node.js 24+ and npm 11+ to clone and build it with the commands below. Save the example in that repository as an .mjs file.

git clone https://github.com/sieblyio/hyperliquid-api.git
cd hyperliquid-api
npm ci
npm run build

REST walkthrough

After building the preview SDK, read public BTC perpetual data with RestClient. These public requests require no credentials.

Save the code as rest-public.mjs and run:

node rest-public.mjs
import { RestClient } from '@siebly/hyperliquid-api'; const client = new RestClient(); async function main() {  try {    const status = await client.getExchangeStatus();    console.log('Exchange status:', status);  } catch (error) {    console.error('Exchange-status request failed:', error);  }   try {    const mids = await client.getAllMids();    console.log('BTC midpoint:', mids.BTC);  } catch (error) {    console.error('Midpoint request failed:', error);  }   try {    const metadata = await client.getPerpMetadata();    const btc = metadata.universe.find((asset) => asset.name === 'BTC');    console.log('BTC perpetual metadata:', btc);  } catch (error) {    console.error('Perpetual metadata request failed:', error);  }   try {    const orderBook = await client.getOrderBook({      coin: 'BTC',    });    console.log('Best bid:', orderBook?.levels[0][0]);    console.log('Best ask:', orderBook?.levels[1][0]);  } catch (error) {    console.error('Order-book request failed:', error);  }   try {    const candles = await client.getCandles({      coin: 'BTC',      interval: '1h',      startTime: Date.now() - 24 * 60 * 60 * 1000,    });    console.log('Latest hourly candle:', candles.at(-1));  } catch (error) {    console.error('Candle request failed:', error);  }   try {    const trades = await client.getRecentTrades({      coin: 'BTC',    });    console.log('Most recent trade:', trades[0]);  } catch (error) {    console.error('Recent-trade request failed:', error);  }} main();

Expected response

Market values change on each run. These are the fields to check in the logged output.

FieldExpected result
BTC midpoint / metadataA decimal-string midpoint and a perpetual asset object from universe.
Best bid / Best askObjects with decimal-string px and sz, plus order count n.
Latest hourly candle / Most recent tradeA candle object with millisecond t and T, OHLC and volume strings; a trade with coin, px, sz, and side.

More REST examples

Full Hyperliquid course

Hyperliquid API JavaScript Tutorial

A practical JavaScript guide to using @siebly/hyperliquid-api for Hyperliquid market data, account state, perpetual and Spot orders, WebSocket streams, WebSocket API requests, Testnet, proxies, and recovery.

Perpetual and Spot REST API calls
Public and account WebSocket streams
Testnet order workflows
REST API and WebSocket proxy examples
REST API
WebSocket Streams
WebSocket API
Examples

Your app / service

bot, dashboard, worker

@siebly/hyperliquid-api

RestClient, WebsocketClient, WebsocketAPIClient

Hyperliquid APIs

Info requests, signed Exchange actions, streaming subscriptions, and WebSocket POST requests

Common Hyperliquid implementation tasks

Hyperliquid JavaScript FAQ

What does the Hyperliquid JavaScript SDK cover?

Hyperliquid supports Spot, Futures, WebSockets, and WebSocket API workflows. The JavaScript guide covers the main REST and WebSocket integration patterns.

How do I authenticate private Hyperliquid API calls in JavaScript?

The public REST example above needs no credentials. For private calls, follow the authentication setup for @siebly/hyperliquid-api in the full tutorial, including the credentials or signer required by your exchange.

Hyperliquid authentication and setup

Does the Hyperliquid JavaScript SDK help with WebSocket connection management?

Yes. Use the SDK WebSocket client for subscriptions, reconnect handling, and stream lifecycle management instead of building raw socket flows yourself.

When should I use the Hyperliquid WebSocket API instead of REST?

Use REST for standard request and response workflows such as account queries and order management. Use the WebSocket API flow when you want persistent low-latency interactions over a connected session.

Direct Example Files

Continue with implementation resources

Subscribe on Substack

Complete the Substack form below to join our newsletter. Substack handles all subscriber data directly.