Spot
Example code snippets to query the indexer for spot market module related data.
Using gRPC
Fetch markets
import { IndexerGrpcSpotApi } from '@injectivelabs/sdk-ts'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'
const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcSpotApi = new IndexerGrpcSpotApi(endpoints.indexer)
const markets = await indexerGrpcSpotApi.fetchMarkets()
console.log(markets)Fetch market based on market id
import { IndexerGrpcSpotApi } from '@injectivelabs/sdk-ts'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'
const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcSpotApi = new IndexerGrpcSpotApi(endpoints.indexer)
const marketId = '0x...'
const market = await indexerGrpcSpotApi.fetchMarket(marketId)
console.log(market)Fetch market's orders
Fetch market's order history
Fetch market's trades
Fetch list of subaccount orders
Fetch list of subaccount trades
Fetch orderbooks for multiple markets
Fetch orderbook for a market
Using HTTP REST
Fetch market summary, such as a history of prices and 24 hr volume
Fetch all markets summaries, such as a history of prices and 24 hr volume
Last updated
