Skip to main content

api

This module exposes the SDK's GMX REST API endpoint lookup helpers.

Functions

getApiUrl

getApiUrl(chainId: number): string | undefined

Returns the configured GMX REST API base URL for a chain, or undefined when that chain does not have API support.

import { getApiUrl } from "@gmx-io/sdk/configs/api";

console.log(getApiUrl(42161)); // Arbitrum API URL
console.log(getApiUrl(43114)); // Avalanche API URL
console.log(getApiUrl(421614)); // Arbitrum Sepolia API URL
console.log(getApiUrl(3637)); // undefined (no public API URL)

isApiSupported

isApiSupported(chainId: number): boolean

Returns true when getApiUrl(chainId) resolves to a GMX API endpoint.

Current support:

  • Arbitrum (42161)
  • Avalanche (43114)
  • Arbitrum Sepolia (421614)

Current non-support:

  • Botanix (3637)
  • Avalanche Fuji (43113)
import { isApiSupported } from "@gmx-io/sdk/configs/api";

isApiSupported(42161); // true
isApiSupported(421614); // true
isApiSupported(3637); // false