-
Notifications
You must be signed in to change notification settings - Fork 195
02QueryingIndexerMarkets
Ivan Angelkoski edited this page Jun 12, 2023
·
4 revisions
Example code snippets to query the indexer for all markets data
- get the marketsHistory resolution: MARKETS_HISTORY_CHART_ONE_HOUR, countback: MARKETS_HISTORY_CHART_SEVEN_DAYS
import { IndexerRestMarketChronosApi } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const indexerRestMarketChronosApi = new IndexerRestMarketChronosApi(
`${endpoints.chronos}/api/chronos/v1/market`
);
const SelectList = {
Hour: "60",
Day: "1d",
Week: "7d",
};
const marketIds = ["0x"];
const countback = 154; // in unit of hours
const resolution = SelectList.Day;
const marketsHistory = await indexerRestMarketChronosApi.fetchMarketsHistory({
marketIds,
resolution,
countback,
});
console.log(marketsHistory);
Powering the future of decentralized finance.