Skip to main content

Getting Started

If you only need read-only HTTP data without RPC calls, use the read-only API client:

Install the shared SDK package first:

npm install @gmx-io/sdk

Then import the read-only client from the v2 subpath:

import { GmxApiSdk } from "@gmx-io/sdk/v2";

const apiSdk = new GmxApiSdk({ chainId: 42161 }); // Arbitrum

const markets = await apiSdk.fetchMarkets();
const marketsInfo = await apiSdk.fetchMarketsInfo();
const tickers = await apiSdk.fetchMarketsTickers({
symbols: ["BTC/USD"],
});
const tokens = await apiSdk.fetchTokens();
const tokensData = await apiSdk.fetchTokensData();
const pairs = await apiSdk.fetchPairs();
const rates = await apiSdk.fetchRates({ period: "7d" });
const apy = await apiSdk.fetchApy({ period: "7d" });
const annualized = await apiSdk.fetchPerformanceAnnualized({
period: "30d",
});
const snapshots = await apiSdk.fetchPerformanceSnapshots({
period: "30d",
});
const positions = await apiSdk.fetchPositionsInfo({
address: "0x9f7198eb1b9Ccc0Eb7A07eD228d8FbC12963ea33",
includeRelatedOrders: true,
});
const orders = await apiSdk.fetchOrders({
address: "0x9f7198eb1b9Ccc0Eb7A07eD228d8FbC12963ea33",
});
const candles = await apiSdk.fetchOhlcv({
symbol: "BTC/USD",
timeframe: "1h",
limit: 100,
});

GmxApiSdk calls the GMX REST API directly — no RPC endpoint, oracle URL, or Subsquid URL required. It supports Arbitrum, Avalanche, and Arbitrum Sepolia. The constructor throws for unsupported chains.

@gmx-io/sdk/v2 is an import path inside the @gmx-io/sdk package, not a separate npm package.

If you're using CommonJS, require the v2 client from the v2 subpath:

const { GmxApiSdk } = require("@gmx-io/sdk/v2");

const apiSdk = new GmxApiSdk({ chainId: 42161 });

TypeScript subpath resolution is supported for @gmx-io/sdk/v2 and the SDK's utility, config, ABI, and type-only entrypoints.

What SDK v2 covers today

WorkflowStatusNotes
Read market catalogs, tickers, and token data over HTTPAvailable through fetchMarkets(), fetchMarketsInfo(), fetchMarketsTickers(), fetchTokens(), and fetchTokensData()
Read pairs, rates, APY, and performance analytics over HTTPAvailable through fetchPairs(), fetchRates(), fetchApy(), fetchPerformanceAnnualized(), and fetchPerformanceSnapshots()
Read one account's positions and orders over HTTPAvailable through fetchPositionsInfo() and fetchOrders()
Read OHLCV candles over HTTPAvailable through fetchOhlcv()
Submit or cancel ordersUse SDK v1 or direct contracts
Trade history readsUse SDK v1 or GraphQL

Use SDK Overview if you want a quick capability comparison before wiring an integration.

Methods

GmxApiSdk exposes the following methods. All of them call the GMX REST API directly -- no RPC, oracle, or Subsquid connection is required.

MethodParametersReturnsNotes
fetchMarkets()--MarketWithTiers[]Market catalog data from /markets
fetchMarketsInfo()--RawMarketInfo[]Market definitions and pricing from /markets/info
fetchMarketsTickers(params?)addresses?: string[], symbols?: string[]MarketTicker[]Filterable market tickers from /markets/tickers
fetchTokens()--Token[]Static token catalog from /tokens
fetchTokensData()--TokenData[]Token metadata and current prices from /tokens/info
fetchPairs()--Pair[]Pair-level summary data from /pairs
fetchRates(params?)period?: ApiParameterPeriod, `averageBy?: "1d""7d""30d", address?: string`
fetchApy(params?)period?: ApiParameterPeriodApyResponseMarket and GLV APY data from /apy
fetchPerformanceAnnualized(params?)period?: ApiParameterPeriod, address?: stringPerformanceAnnualized[]Annualized performance summaries from /performance/annualized
fetchPerformanceSnapshots(params?)period?: ApiParameterPeriod, address?: stringPerformanceSnapshots[]Historical performance snapshot series from /performance/snapshots
fetchPositionsInfo(params)address: string, includeRelatedOrders?: booleanApiPositionInfo[]Position objects for an address; optionally includes related orders
fetchOrders(params)address: stringApiOrderInfo[]Active order objects for an address
fetchOhlcv(params)symbol: string, timeframe: string, limit?: number, since?: numberOhlcvCandle[]OHLCV candle data from /prices/ohlcv

When to use SDK v2

Use GmxApiSdk for read-only API integrations that need market, ticker, token, pair, rate, APY, performance, position, order, or OHLCV data without requiring RPC or oracle connections. Use the full GmxSdk (SDK v1) when you need trade history or write operations such as submitting or cancelling orders.

note

GmxApiSdk is under active development and will expand to cover the full SDK surface over time, replacing the need for direct RPC, oracle, and Subsquid connections. The OpenAPI Reference documents the underlying REST API that GmxApiSdk wraps.