Skip to content

Hyperliquid API SDK ​

@siebly/hyperliquid-api provides JavaScript and TypeScript clients for Hyperliquid market data, account queries, signed trading actions and WebSocket subscriptions.

Build trading bots and automate your strategies in Node.js, or use real-time market data in a dashboard. Start with a public price request, then add authentication and order handling for your trading workflow.

JavaScript & TypeScript · v1.0.2 · MIT license

Installation ​

TypeScript definitions are included.

sh
npm install @siebly/hyperliquid-api
sh
pnpm add @siebly/hyperliquid-api
sh
yarn add @siebly/hyperliquid-api

Choose your setup ​

Start with the tools you already use. Each guide includes a complete project, setup commands, expected output and cleanup where applicable.

  • Node.js / JavaScript: run plain JavaScript with import or require, without a TypeScript compiler.
  • Node.js / TypeScript: type-check and compile a Node.js price and subscription script.
  • React: display live prices in a React component with effect cleanup, using Vite.
  • Vite (plain JavaScript): display prices in a browser page without React.
  • Next.js: return a price from a Node.js server Route Handler.
  • React Native / Expo: display prices and stop subscriptions on iOS and Android.
  • Bun and Deno: run a price and WebSocket script in your chosen runtime.

Each guide includes a downloadable starter generated from the maintained examples and runtime configuration. Runtime compatibility records tested versions and scope.

Usage ​

RestClient.getAllMids() reads current mid prices without a wallet or private key.

js
import { RestClient } from '@siebly/hyperliquid-api';

async function main() {
  const client = new RestClient();
  const mids = await client.getAllMids();
  if (mids.BTC === undefined) {
    throw new Error('BTC was not present in the mid-price response.');
  }
  console.log('BTC mid price:', mids.BTC);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

The example prints the BTC mid price. Save it as prices.mjs and run node prices.mjs. See the Node.js quickstart for module formats and example output.

Clients ​

ClientPurpose
RestClientQuery market data and account state, or submit signed actions over HTTP.
WebsocketClientSubscribe to market data and account updates.
WebsocketAPIClientCall the REST client's methods over a WebSocket connection.

See Clients for setup and cleanup, or the API reference for methods and types.

Common tasks ​

TaskGuide
Read prices, order books and candlesMarket data
Receive market updatesWebSocket subscriptions
Query accounts or configure a signerAuthentication
Choose a network and set timeoutsConfiguration

Using the SDK ​

Error handling covers failed requests and rejected orders. Production usage covers retries, recovery and shutdown. Start with Troubleshooting for a specific failure.

For a longer walkthrough, see the Hyperliquid JavaScript tutorial on Siebly.io.

Built by Siebly. Open source SDKs for exchange APIs.