Single api to fetch all stock list with real time data

Hi Team
I need single api to fetch all stocks list with real time data and also how to integrate stocks, indices real time data chart in my website.

You can access the complete list of stocks in CSV format from the Upstox website at Instruments | Upstox Developer API, which is available for download and use.

For charting purposes, consult the documentation provided at Historical Data | Upstox Developer API.

For real-time data, itā€™s recommended to use the WebSocket. More information and details can be found at Market Data Feed | Upstox Developer API and Sample Implementation | Upstox Developer API.

Itā€™s advisable to familiarize yourself with the documentation and understand the API thoroughly before implementing it. This approach will assist in achieving your objectives more effectively.

2 Likes

Hi Team
We have followed above shared documentation, but after generating access code, unable to generate tokenā€¦ Hereby sharing error belowā€¦ Just have a look and let me know solution for the same.

Summary

Screenshot by Lightshot

@sam_jain1995,

From the screenshot you shared, it looks like the Auth code being utilized is not valid. It appears to contain additional, unnecessary data. Normally, an Auth code is sent to the redirect_uri and follows a specific format:

https://<redirect_uri>?code=xxxxxx

Here, xxxxxx represents the actual Auth code. I suggest attempting again with the correct Auth code, adhering to the format mentioned. Using the proper code should effectively address the issue.

Thank you!

The error message indicates an issue with an invalid token. Additionally, itā€™s important to note that the auth token is only valid for a single use. Below is the functional and verified code:

curl --location 'https://api-v2.upstox.com/login/authorization/token' \
--header 'accept: application/json' \
--header 'Api-Version: 2.0' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'code={auth_code}' \
--data-urlencode 'client_id={auth_code}' \
--data-urlencode 'client_secret={client_secret}' \
--data-urlencode 'redirect_uri={redirect_uri} \
--data-urlencode 'grant_type=authorization_code'

Hi Team
Using above same URL and exact code, still showing same error invalid auth code

Error Code - UDAPI100057

https://prnt.sc/Q7vyqMdkjRR2

@sam_jain1995

Could you please share the cURL command for the API call that didnā€™t work? Just make sure to omit the client_id and secret for security reasons.

Thanks!

curl -X ā€˜POSTā€™ ā€˜https://api.upstox.com/v2/login/authorization/tokenā€™
-H ā€˜accept: application/jsonā€™
-H ā€˜Api-Version: 2.0ā€™
-H ā€˜Content-Type: application/x-www-form-urlencodedā€™
-d ā€˜code=&client_id=&client_secret=&redirect_uri=https://abc.in&grant_type=authorization_codeā€™

Hi Team
Any updates on this?

is your access token generated

Not yet. Unable to generate access token

bro as document suggest access token is required

Hi Team

Using This

https://api-v2.upstox.com/login/authorization/token
?client_id=c411XXXX&client_secret=evXXXX&code=WXXX&grant_type=authorization_code&redirect_uri=https://fu.in/

errorCode": ā€œUDAPI100060ā€,
ā€œmessageā€: ā€œResource not Found.ā€,

Unable to generate access token

same error to me i tried using app.post and now getting error.
is authentication code is generated after login

Hi Team
Can you please assist in generating access token, we are following exact same procedure but even after that getting error

Using This

https://api-v2.upstox.com/login/authorization/token
?client_id=c411XXXX&client_secret=evXXXX&code=WXXX&grant_type=authorization_code&redirect_uri=https://fu.in/

errorCode": ā€œUDAPI100060ā€,
ā€œmessageā€: ā€œResource not Found.ā€,

Unable to generate access token

@vinod_mokashi @sam_jain1995

The following cURL command is functioning correctly. Please ensure that all necessary parameters are included as specified. Additionally, a sample authentication code is included in the cURL command to help clarify the required format, in case there was any confusion about it.

curl --location 'https://api.upstox.com/v2/login/authorization/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--data-urlencode 'client_id=<client_id>' \
--data-urlencode 'client_secret=<client_secret>' \
--data-urlencode 'code=gUYpiy' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'redirect_uri=<redirect_uri>'

To bypass potential local coding issues, I recommend testing the provided cURL command using Postman. This will help determine if the problem is with the code or elsewhere.

Thanks!!!

Hi Team
Can we please connect on call regarding the same

i checked at postman still error is present

yes we can connect and let solve it

@vinod_mokashi,

I recommend testing the provided cURL command in Postman. The screenshot you shared shows your applicationā€™s endpoint being used which is not intended. Running the cURL I previously shared will help pinpoint the issue more clearly.

@sam_jain1995, @vinod_mokashi

Hereā€™s the cURL command for you to execute. Please fill in appropriate data and try it out:

curl --location 'https://api.upstox.com/v2/login/authorization/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--data-urlencode 'client_id=<client_id>' \
--data-urlencode 'client_secret=<client_secret>' \
--data-urlencode 'code=gUYpiy' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'redirect_uri=<redirect_uri>'

Itā€™s crucial to identify the root cause rather than delving into code debugging prematurely. This cURL test will clarify where the issue lies, enabling us to proceed logically. Please share the results after executing this test.

Thank you for understanding the importance of this step in the troubleshooting process.

1 Like