Need help with the market feed web socket implementation

Hi @Belal_Ahmad,

Each instrument has a unique instrument key. You’ll need to identify the instrument key for each instrument from this JSON file: Instruments | Upstox Developer API.

Once you have the instrument keys, pass them as an array to the market feeder. Below is an example using the Node.js SDK:

let UpstoxClient = require("upstox-js-sdk");
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications["OAUTH2"];
OAUTH2.accessToken = <ACCESS_TOKEN>;

const streamer = new UpstoxClient.MarketDataStreamerV3();
streamer.connect();

// Subscribe to instrument keys after the 'open' event
streamer.on("open", () => {
  streamer.subscribe(["NSE_EQ|INE020B01018", "NSE_EQ|INE467B01029"], "full");
});

// Handle incoming market data messages
streamer.on("message", (data) => {
  const feed = data.toString("utf-8");
  console.log(feed);
});

For further details, please refer to the documentation:


Thank you

1 Like