Spot

Example code snippets to stream from the indexer for spot market module related data.

Using gRPC Stream

Stream the spot orderbook

import { IndexerGrpcSpotStream } from '@injectivelabs/sdk-ts'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcSpotStream = new IndexerGrpcSpotStream(endpoints.indexer)

const marketIds = ['0x...']

const streamFn = indexerGrpcSpotStream.streamSpotOrderbookV2.bind(
  indexerGrpcSpotStream,
)

const callback = (orderbooks) => {
  console.log(orderbooks)
}

const streamFnArgs = {
  marketIds,
  callback,
}

streamFn(streamFnArgs)

Stream spot orders

Stream spot order history

Stream spot trades

Stream markets

Stream orderbook updates

Last updated