Getting Error: Resource Not Found while fetching quotes for NSE_EQ


Getting ResourceNotFound Error during getting quotes for NSE_EQ stocks.

The code I written is as below:

def get_quote(stock_symbol):
“”" Fetch live market data “”"
access_token = get_access_token()
if not access_token:
return None

#url = "https://api.upstox.com/v2/market-quote/quotes"
url = "https://api.upstox.com/v2/market-quote/instruments"
#url = "https://api.upstox.com/v2/instruments"
#url = 'https://api.upstox.com/v2/market-quote/ohlc'
#params = {"symbols": stock_symbol}
payload = {
        "instrument_key": [stock_symbol],
        #"interval": "1d"
}
headers = {
    "Authorization": f"Bearer {access_token}",
    "Accept": "application/json"
}
response = requests.request("GET", url, headers=headers, data=payload)  
return response.json()

Example usage

print(get_quote(“NSE_EQ|INFY”))

As the error message indicates, the endpoint you are trying to access is invalid. Please refer to the example codes for the correct implementation:

Thanks!

1 Like