How to Fetch Instrument (Stocks,Indices) Charts with real time data

Hi Team
I have Generated Access Token, Now I want to fetch charts of each instrument (stock&indices) along with real time data.

Have tried trading-view iframe but chart is not giving real time data

Hi Team
Any update on this?

To access the candle data, kindly refer to the historical section of the application at this link: Historical Data | Upstox Developer API.

Additionally, it would be recommended to acquaint yourself with the instruments file available here: https://upstox.com/developer/api-documentation/instruments."

To access real-time data, it’s necessary to incorporate a WebSocket. You can find guidance on WebSocket integration in the documentation at Upstox’s API Documentation on Market Data Feed. Additionally, examples in various programming languages are available at Upstox’s Sample Implementation.

1 Like

hi, my backend on php and frontend on react so how i have to go.
i have confusion because ‘Upstox’s Sample Implementation’ showing backend code. if i implement on backend then what i have to do for got on front UI.

Should i have to create api or my own web-socket?

Hi @Pradeep_Jaiswar
Can you please assist for the same?

You can establish your own websocket, enabling the transmission of data to your React frontend application. Whenever you establish a websocket connection to Upstox from your backend, you can temporarily store this data on the server and then relay it to your frontend application.

Additionally, we’re in the process of developing a sample React application, which we plan to make available soon.

Hi @Pradeep_Jaiswar
After implementing socket, how can I get this kind of view for the graphs
Since, websocket or API would give only data not graph … How we would represent or render on frontend like this?

Hi Team @Pradeep_Jaiswar @shanmu
Can you please assist for the same?

Thanks

I suggest you check ChartIQ SDK Documentation and Lightweight Charts™ library — TradingView India for chart integration on your side.

The further development of planning and logic for your application is something that needs to be managed within your scope of work. We appreciate your understanding in this matter. However, if you encounter any problems with the Upstox API itself, please feel free to write to us for assistance. Thank you for reaching out.

Thank you!

Hi Team @Pradeep_Jaiswar

Hi Team
I just want chart iframe for demo trading just to showcase stocks chart on html page with live market rates… For this I have used trading-view widget but its not showing real-time data

Unfortunately, we cannot provide support for chart integration. We recommend consulting with a specialist who can assist you in this area. Nonetheless, if you face any challenges related to the Upstox API, please don’t hesitate to contact us for help.

‘Upstox’s Sample Implementation’ is integrated and well work. i have establish my own websocket, enabling the transmission of data to my React frontend application.
currently it return [“NSE_INDEX|Nifty Bank”, “NSE_INDEX|Nifty 50”] data. now i want to do this dynamic according to user request.

if i use
ws.send(Buffer.from(JSON.stringify(
{
guid: “someguid”,
method: “sub”,
data: {
mode: “full”,
instrumentKeys: [“NSE_INDEX|Nifty Bank”, “NSE_INDEX|Nifty 50”],
},
})));

it broadcast same data to my all app users.
now i need any emit event which return data according to user request so i can forward to my particular app user
please share method or event if have any

@Pradeep_Jaiswar waiting your response

You’ll need to manage a subscription for each user in your code, ensuring updates are provided to those subscribed to a specific symbol.

However, this approach represents a client-side application logic on your end. We advise seeking guidance from an expert in this field for your app development. Nonetheless, if you face any challenges related to the Upstox API, please don’t hesitate to contact us for help.

@Pradeep_Jaiswar I want get the latest live price through API.
IS used the market-quote Upstox API. But this API get symbol name is below format symbol=NSE_EQ|INE848E01016.
but I passed the symbol name like as NSE_INDEX|NIFTY MIDCAP 150.
when I passed this formate symbol then it is does not response.
please provide the solution.

Ensure that the URL is encoded as NSE_INDEX%7CNIFTY%20MIDCAP%20150

The following is a functional curl request. Rest assured, this code has been tested and is operational

curl --location 'https://api-v2.upstox.com/market-quote/quotes?symbol=NSE_INDEX%7CNIFTY%20MIDCAP%20150' \
--header 'accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' 

I using upstox socket for the stock live price.
But in this socket I have get only some stocks data.
I send money instrument Keys.
But this is response some stocks live data.
For Ex. In CSV file all BSE and NSE stock names. I passed this data in socket.
but some time it is not respose.
Please solve this issue.

Hi @Pradeep_Jaiswar @shanmu
Can you please assist for the same?

I am using Upstox socket for retrieving live stock prices. However, I am only receiving data for some stocks. I have tried sending multiple instrument keys, including all BSE and NSE stock names from a CSV file, but sometimes I do not get a response. Can you please help me resolve this issue?

Also in socket, I’m getting data with instrument key but I want to show Stock Name there instead of instrument key, kindly assist for the same

Hi Team @Pradeep_Jaiswar @shanmu

Kindly revert for the above.

Also, daily auth-code and token are expiring, is there any alternative or some method to regenerate or update automatically

Hope to hear from you soon.

Thanks

@Akash_choudhary @sam_jain1995

The market feed websocket will provide real-time updates for the instrument keys you subscribe to. If there are any inconsistencies in the updates you’re receiving, please provide a detailed example along with evidence, so we can investigate further.

Additionally, @sam_jain1995, please note that the access_token is only valid until 3:30 AM on the day following its issuance. After this, you’ll need to log in again to generate a new token using the OAuth process. If you’re using a multi-client application, there’s an option to obtain an extended token with a longer lifespan. For more information on this, check the following link: Extended Token Information.

Automation of regenerating an access token is not advisable as per the regulatory and SEBI guidelines.

Thank you!