Package detail

@nktkas/hyperliquid

nktkas321.1kMIT0.30.0

Hyperliquid API SDK for all major JS runtimes, written in TypeScript.

api, library, sdk, javascript

readme

Hyperliquid API TypeScript SDK

npm jsr Downloads coveralls bundlephobia

@nktkas/hyperliquid is a TypeScript SDK for the Hyperliquid API.

Features

  • 🖋️ Typed: Source code is 100% TypeScript.
  • 🧪 Tested: Good code coverage and type relevance.
  • 📦 Minimal dependencies: A few small trusted dependencies.
  • 🌐 Cross-Environment Support: Compatible with all major JS runtimes.
  • 🔧 Integratable: Easy to use with wallet providers (viem or ethers).

Installation

npm i @nktkas/hyperliquid

Quick Example

import { ExchangeClient, HttpTransport, InfoClient } from "@nktkas/hyperliquid";
import { privateKeyToAccount } from "viem/accounts";

// Read data
const info = new InfoClient({ transport: new HttpTransport() });
const mids = await info.allMids();
console.log(mids); // { "BTC": "97000.5", "ETH": "3500.25", ... }

// Place order
const exchange = new ExchangeClient({
  transport: new HttpTransport(),
  wallet: privateKeyToAccount("0x..."),
});

const result = await exchange.order({
  orders: [{
    a: 0, // Asset index (BTC)
    b: true, // Buy side
    p: "95000", // Price
    s: "0.01", // Size
    r: false, // Reduce only
    t: { limit: { tif: "Gtc" } },
  }],
  grouping: "na",
});

Documentation

📚 Read the full documentation

Star History

<picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=nktkas/hyperliquid&type=date&theme=dark&legend=top-left" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=nktkas/hyperliquid&type=date&legend=top-left" /> Star History Chart </picture>