Hyperliquid API TypeScript SDK

Hyperliquid API SDK written in TypeScript

  • 0 Raised
  • 512 Views
  • 0 Judges

Categories

  • 01. 🛠️ Public Goods
  • 08. Best use of Privy
  • 11. Hyperliquid SDK in other languages

Description

🧠 Project Name

Hyperliquid API TypeScript SDK

🔍 Description

TypeScript SDK that fully implements interaction with Hyperliquid API.

🛠️ How It Works

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

  • 100% TypeScript with full type safety
  • Modular architecture: independent transport layer, signing layer, API types, unified client
  • Minimal trusted dependencies
  • Cross-runtime compatibility (Node.js, Deno, browsers, React Native)

API Coverage

  • Complete Hyperliquid API implementation beyond official Python SDK scope (list)
  • Multi-sig support with minimal code changes to existing implementations

Developer Experience

  • JSDoc documentation with inline usage examples
  • Easy integration with any libraries providing viem/ethers compatible wallet interface (e.g. privy)
  • Comprehensive test coverage and type relevance

💻 Usage Example

Info endpoint

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

Exchange endpoint

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

Subscription

// 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();

Multi-Sign

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

📂 Project Links

👥 Team

  • nktkas (Owner)