i want to create a feed like this lets say i subscribe to 50 stocks and the data i want is ohlc,ltp,price of all those stocks all i want to know how can i subscribe to these stocks not indices also if anyone has the implementation in node js
@Belal_Ahmad this UI looks nice? did you build it? is it on top of Upstox API?
to answer your question - yes you can use the NodeJS API to subscribe to stocks and stream it to your frontend. We have an SDK that makes it easy and straightforward to subscribe and unsubscribe at the server end - youâll have to build the logic to stream it to your front end - maybe ChatGPT or some LLM can help here.
my question if i want to subscribe lets say 50 stocks and what would be the instrument key i have send to subscribe
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