Hyperliquid API TypeScript SDK
TypeScript SDK that fully implements interaction with Hyperliquid API.
SDK wraps Hyperliquid's raw API into TypeScript interfaces.
Developers simply pass any wallet created through a wallet library (viem or ethers) and specify the desired transport layer (HTTP or WebSocket), and can start interacting with the Hyperliquid API.
Features
Technical Foundation
API Coverage
Developer Experience
// 1. Import module
import * as hl from "@nktkas/hyperliquid";
// 2. Set up client with transport
const infoClient = new hl.InfoClient({
transport: new hl.HttpTransport(), // or `WebSocketTransport`
});
// 3. Query data
const openOrders = await infoClient.openOrders({ user: "0x..." });// 1. Import module
import * as hl from "@nktkas/hyperliquid";
// 2. Set up client with wallet and transport
const exchClient = new hl.ExchangeClient({
wallet: "0x...", // `viem`, `ethers`, or private key directly
transport: new hl.HttpTransport(), // or `WebSocketTransport`
});
// 3. Execute an action
const response = await exchClient.order({
orders: [{
a: 0,
b: true,
p: "30000",
s: "0.1",
r: false,
t: {
limit: {
tif: "Gtc",
},
},
}],
grouping: "na",
});// 1. Import module
import * as hl from "@nktkas/hyperliquid";
// 2. Set up client with transport
const subsClient = new hl.SubscriptionClient({
transport: new hl.WebSocketTransport(),
});
// 3. Subscribe to events
const sub = await subsClient.allMids((event) => {
console.log(event);
});
await sub.unsubscribe();// 1. Import module
import * as hl from "@nktkas/hyperliquid";
// 2. Set up client with transport, multi-sign address, and signers
const multiSignClient = new hl.MultiSignClient({
transport: new hl.HttpTransport(), // or `WebSocketTransport`
multiSignAddress: "0x...",
signers: [
"0x...", // `viem`, `ethers`, or private key directly
],
});
// 3. Execute an action (same as `ExchangeClient`)
await multiSignClient.approveAgent({ agentAddress: "0x..." });