Skip to content

02StreamingIndexerPortfolio

Ivan Angelkoski edited this page Jun 12, 2023 · 4 revisions

⚠️ The Docs have been moved to https://docs.ts.injective.network/querying/querying-api/streaming/streaming-indexer-portfolio ⚠️

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

Using gRPC Stream

  • stream an account's portfolio
import { IndexerGrpcAccountPortfolioStream } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";

const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const indexerGrpcAccountPortfolioStream = new IndexerGrpcAccountPortfolioStream(
  endpoints.indexer
);

const accountAddress = "inj...";

const streamFn = indexerGrpcAccountPortfolioStream.streamAccountPortfolio.bind(
  indexerGrpcAccountPortfolioStream
);

const callback = (portfolioResults) => {
  console.log(portfolioResults);
};

const streamFnArgs = {
  accountAddress,
  callback,
};

streamFn(streamFnArgs);

⚠️ DOCUMENTATION ⚠️

Clone this wiki locally