Market Data
This section covers how to fetch market information, statistics, and real-time data from the Nord API.
[!NOTE] Other languages: See Python Market Data for Python examples, or REST API Reference for raw HTTP endpoints.
Nord Info Endpoint
The /info endpoint returns all available markets and tokens without requiring a Nord instance.
Endpoint: GET /info
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| None | - | - | This endpoint takes no parameters. |
Response Structure
The response is a JSON object containing arrays of markets and tokens.
{
"markets": [
{
"marketId": number,
"symbol": string,
"baseTokenId": number,
"quoteTokenId": number,
"priceDecimals": number,
"sizeDecimals": number,
// ... other market properties
}
],
"tokens": [
{
"tokenId": number,
"symbol": string,
"decimals": number,
"mint": string,
// ... other token properties
}
]
}Example
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);Market Statistics
The /market/{marketId}/stats endpoint provides detailed statistics for a specific market, including funding rate, mark price, and 24h metrics.
Endpoint: GET /market/{marketId}/stats
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
marketId | number | Yes | The unique identifier of the market (e.g., 0 for BTC/USDC). |
Response Structure
{
"marketId": number,
"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
}
}Example
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);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