Quick Start

Get started with the SDK in just a few lines of code.

1

Set up Transport

First, create a Transportarrow-up-right - the layer that handles communication with Hyperliquid servers.

Use HttpTransportarrow-up-right for simple requests.

import { HttpTransport } from "@nktkas/hyperliquid";

const transport = new HttpTransport();
2

Create a Client

Next, create a Clientarrow-up-right with your transport. The SDK provides three clients for different purposes:

Use Infoarrow-up-right to query market data, account state, and other read-only information.

import { HttpTransport, InfoClient } from "@nktkas/hyperliquid";

const transport = new HttpTransport();
const info = new InfoClient({ transport });
3

Use the Client

Call client methods to query data, place orders, or subscribe to streams.

// 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" });

Last updated