Skip to Content
Usage ExamplesMarket Data

Market Data

This section covers how to fetch market information, statistics, and real-time data from the Nord API.

Nord Info Endpoint

The /info endpoint returns all available markets and tokens without requiring a Nord instance.

const NORD_URL = "https://zo-mainnet.n1.xyz"; // or "https://zo-devnet.n1.xyz" for devnet // Fetch all markets and tokens const response = await fetch(`${NORD_URL}/info`); const data = await response.json(); console.log('Markets:', data.markets); console.log('Tokens:', data.tokens);

Response Structure

interface InfoResponse { markets: Market[]; // Array of all available markets tokens: Token[]; // Array of all available tokens }

Market Statistics

The /market/{marketId}/stats endpoint provides detailed statistics for a specific market, including funding rate, mark price, and 24h metrics.

const NORD_URL = "https://zo-mainnet.n1.xyz"; const marketId = 0; // BTC/USDC const response = await fetch(`${NORD_URL}/market/${marketId}/stats`); const stats = await response.json(); console.log('Index Price:', stats.indexPrice); console.log('Funding Rate:', stats.perpStats.funding_rate); console.log('Mark Price:', stats.perpStats.mark_price); console.log('Open Interest:', stats.perpStats.open_interest); console.log('24h Volume (Quote):', stats.volumeQuote24h);

Response Structure

interface MarketStats { indexPrice: number; // Current index price indexPriceConf: number; // Index price confidence interval volumeBase24h: number; // 24h volume in base asset volumeQuote24h: number; // 24h volume in quote asset (USDC) high24h: number; // 24h high low24h: number; // 24h low close24h: number; // 24h close prevClose24h: number; // Previous 24h close perpStats: { mark_price: number; // Current mark price funding_rate: number; // Current funding rate next_funding_time: string; // Next funding timestamp open_interest: number; // Total open interest aggregated_funding_index: number; // Aggregated funding index }; }

Fetching Multiple Market Stats

To fetch statistics for multiple markets efficiently:

const NORD_URL = "https://zo-mainnet.n1.xyz"; const marketIds = [0, 1, 2]; // BTC, ETH, SOL const statsPromises = marketIds.map(async (marketId) => { const response = await fetch(`${NORD_URL}/market/${marketId}/stats`); return response.json(); }); const allStats = await Promise.all(statsPromises); allStats.forEach((stats, i) => { console.log(`Market ${marketIds[i]} Funding Rate:`, stats.perpStats?.funding_rate); });

Using Nord Client

If you have a Nord instance, you can use the built-in methods:

import { Nord } from "@n1xyz/nord-ts"; // Assuming nord is already initialized // Get orderbook for a market const orderbook = await nord.getOrderbook({ marketId: 0 }); console.log('Bids:', orderbook.bids); console.log('Asks:', orderbook.asks); // Get recent trades const trades = await nord.getTrades({ marketId: 0, pageSize: 10 }); console.log('Recent trades:', trades.trades); // Subscribe to real-time orderbook updates const orderbookSub = nord.subscribeOrderbook('BTC/USDC'); orderbookSub.on('update', (data) => { console.log('Orderbook update:', data); });
Last updated on