Unofficial Extended API SDK for all major JS runtimes, written in TypeScript and provided with tests.
This package has been heavily inspired by the, also unofficial, Hyperliquid API SDK by @nktkas
- π Type-safe: Full TypeScript support with comprehensive type definitions
- π‘οΈ Runtime validation: Zod schemas for all API responses
- π Modern: Built with modern JavaScript/TypeScript tooling
- π¦ Tree-shakable: Only import what you need
- π§ͺ Well-tested: Comprehensive test suite with real API integration
npm install @rokitgg/extended
# or
pnpm add @rokitgg/extended
# or
yarn add @rokitgg/extendedimport { HttpTransport } from "@rokitgg/extended/transports";
import { InfoClient } from "@rokitgg/extended/clients";
const transport = new HttpTransport();
const infoClient = new InfoClient({ transport });
// Get all markets
const allMarkets = await infoClient.markets();
// Get specific market (using query parameters)
const btcMarket = await infoClient.markets({ market: "BTC-USD" });
// Get multiple markets (using query parameters)
const markets = await infoClient.markets({ market: ["BTC-USD", "ETH-USD"] });// Get market statistics
const stats = await infoClient.marketStats("BTC-USD");
console.log(stats.lastPrice); // Last traded price
console.log(stats.volume24h); // 24-hour volume
console.log(stats.fundingRate); // Current funding rate// Get market order book
const orderBook = await infoClient.marketOrderBook("BTC-USD");
console.log(orderBook.bid); // Array of bid orders
console.log(orderBook.ask); // Array of ask orders// Get recent trades
const trades = await infoClient.marketTrades("BTC-USD");
console.log(trades[0].p); // Trade price
console.log(trades[0].q); // Trade quantity
console.log(trades[0].S); // Trade side (BUY/SELL)// Get candles history
const candles = await infoClient.candles("BTC-USD", "trades", "1m", 1000);
console.log(candles[0].o); // Open price
console.log(candles[0].h); // High price
console.log(candles[0].l); // Low price
console.log(candles[0].c); // Close price
console.log(candles[0].v); // Volume// Get funding history
const endTime = Date.now();
const startTime = endTime - 7 * 24 * 60 * 60 * 1000; // 7 days ago
const fundingHistory = await infoClient.funding("BTC-USD", startTime, endTime);
console.log(fundingHistory.data); // Array of funding rates
console.log(fundingHistory.pagination); // Pagination info// Get open interest history
const endTime = Date.now();
const startTime = endTime - 7 * 24 * 60 * 60 * 1000; // 7 days ago
const openInterest = await infoClient.openInterest("BTC-USD", "P1D", startTime, endTime);
console.log(openInterest[0].i); // Open interest in USD
console.log(openInterest[0].I); // Open interest in synthetic asset
console.log(openInterest[0].t); // TimestampThe HTTP transport for making REST API calls.
import { HttpTransport } from "@rokitgg/extended/transports";
const transport = new HttpTransport({
isTestnet: false, // Use testnet API
timeout: 10000, // Request timeout in ms
});Client for accessing public market information.
import { InfoClient } from "@rokitgg/extended/clients";
const client = new InfoClient({ transport });
// Available methods:
await client.markets(); // Get all markets
await client.marketStats("BTC-USD"); // Get market statistics
await client.marketOrderBook("BTC-USD"); // Get order book
await client.marketTrades("BTC-USD"); // Get recent trades
await client.candles("BTC-USD", "trades", "1m", 1000); // Get candles
await client.funding("BTC-USD", startTime, endTime); // Get funding history
await client.openInterest("BTC-USD", "P1D", startTime, endTime); // Get open interestAll TypeScript types are available for import:
import type {
ExtendedMarketData,
MarketStats,
MarketOrderBook,
MarketTrade,
Candle,
FundingRate,
OpenInterest
} from "@rokitgg/extended/types";Zod schemas for runtime validation:
import {
ExtendedMarketDataSchema,
MarketStatsSchema,
MarketOrderBookSchema,
MarketTradeSchema,
CandleSchema,
FundingRateSchema,
OpenInterestSchema
} from "@rokitgg/extended/schemas";Error classes for handling API errors:
import {
InvalidInputError,
HttpRequestError,
TransportError
} from "@rokitgg/extended/errors";We love contributions from the open source community! This SDK is actively under development and we welcome:
- π Bug fixes and improvements
- β¨ New features and API endpoint support
- π Documentation improvements
- π§ͺ Test coverage enhancements
- π§ Code quality improvements
- Fork the repository on GitHub
- Clone your fork and set up the development environment
- Create a feature branch for your changes
- Make your changes following our coding standards
- Run tests to ensure everything works
- Submit a pull request with a clear description
For detailed contribution guidelines, see our CONTRIBUTING.md file.
git clone https://github.com/rokitgg/extended-sdk.git
cd extended-sdk/packages/sdk
pnpm install
pnpm test # Run tests to verify setupgit clone https://github.com/rokitgg/extended-sdk.git
cd extended-sdk/packages/sdk
pnpm installpnpm buildpnpm testpnpm lint
pnpm lint:fixMIT