Error while extracting the Full Market Quote

I am getting error:
<Response [401]>
While trying to get full market quote:

https://api.upstox.com/v2/market-quote/quotes?instrument_key=NSE_INDEX|Nifty+50

Below is the code i am using:
def get_market_ohlc_quote(self, instrument_keys: list):
“”"
Fetch OHLC Quote snapshots from Upstox for given instruments at specified interval.
interval: ‘1d’ for daily, ‘I1’ for 1-min, ‘I30’ for 30-min.
“”"
try:
keys_str = “,”.join(instrument_keys)
url = f"{self.base_url}/market-quote/quotes"
params = {“instrument_key”: keys_str}
# Prepare the full URL with encoded parameters
req = requests.Request(‘GET’, url, headers=self.get_headers(), params=params)
prepared = req.prepare()
print(f"Full request URL: {prepared.url}“)
response = requests.get(url, headers=self.get_headers(), params=params)
print(response)
#response.raise_for_status()
# Returns a dict with keys as instrument identifiers, each containing the full quote (see Upstox docs)
return response.json().get(“data”, {})
except Exception as e:
logger.error(f"Failed fetching market quote: {e}”)
return None

If it is about authentication:
I am able to extract the historical data:
2025-11-19 12:13:28,143 - INFO - Fetching today’s OHLC intraday candles once.

2025-11-19 12:13:28,707 - INFO - Loaded 178 candles

just 10 seconds before the Full market API Call.

Hi @Sonu_51669323
A 401 status indicates that the access token being used is invalid.
Please regenerate your access token and try again.

You can follow the steps in the official authentication documentation here:

1 Like