Derivatives
Example code snippets to query the indexer for derivative module related data.
Using gRPC
Fetch markets
import { IndexerGrpcDerivativesApi } from '@injectivelabs/sdk-ts'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'
const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcDerivativesApi = new IndexerGrpcDerivativesApi(
endpoints.indexer,
)
const markets = await indexerGrpcDerivativesApi.fetchMarkets()
console.log(markets)Fetch market based on a market id
import { IndexerGrpcDerivativesApi } from '@injectivelabs/sdk-ts'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'
const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcDerivativesApi = new IndexerGrpcDerivativesApi(
endpoints.indexer,
)
const marketId = '0x...'
const market = await indexerGrpcDerivativesApi.fetchMarket(marketId)
console.log(market)Fetch binary options markets
Fetch binary options market based on market id
Fetch a market's orderbook based on market id
Fetch a market's orders
Fetch a market's order history
Fetch a market's positions
Fetch a market's trades
Fetch funding payments for a market
Fetch funding rates for a market
Fetch subaccount orders
Fetch 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
