@nktkas/hyperliquid is a TypeScript SDK for the Hyperliquid API.
- 🖋️ 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).
npm i @nktkas/hyperliquidimport { 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",
});MIT License © 2024-2025 nktkas