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.

1 Like

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