Is the quote endpoint down?

Facing issue in retrieving market quote through ‘quotes’ and ‘ltp’ api endpoints. Seems like it is working for indices but not for option keys

@prsh The market quotes are functioning correctly. Please provide the specific cURL request and its output so we can further assist you.

I am using python with below details for which I am getting empty dict :

self.base_url = "https://api.upstox.com/v2"
self.headers = {
                'accept': 'application/json',
                'Api-Version': '2.0',
                'Content-Type': 'application/json',
                'Authorization': f'Bearer {self.access_token}'  
                 }
endpoint = '/market-quote/'
str_lst = 'NSE_FO|39050'
quoteType == 'ltp':
uri = f"{self.base_url}{endpoint}{quoteType}"
params = {'instrument_key': f'{str_lst}'}
response = requests.get(uri, headers=self.headers, params=params)
if response.status_code == 200:
# Access the response data
         data = response.json()['data']
         print('Quote Data : ')
         print(response.json())
         print('--------')
else:
# Handle any errors
        print('Request failed with status code:', response.status_code)
        print(response.json()['errors'][0]['message'])
        data = None

Output :
Quote Data :
{‘status’: ‘success’, ‘data’: {}}

{}

NSE_FO|39050 is not a valid instrument key. Please refer to Upstox Instruments for correct and updated instrument keys.

Here is an working example of your code

import requests

def funf():
    base_url = "https://api.upstox.com/v2"
    headers = {
                    'accept': 'application/json',
                    'Api-Version': '2.0',
                    'Content-Type': 'application/json',
                    'Authorization': f'Bearer {access_token}'
                     }
    endpoint = '/market-quote/'
    str_lst = 'NSE_EQ|INE669E01016'
    quoteType = 'ltp'
    uri = f"{base_url}{endpoint}{quoteType}"
    params = {'instrument_key': f'{str_lst}'}
    response = requests.get(uri, headers=headers, params=params)
    if response.status_code == 200:
    # Access the response data
             data = response.json()['data']
             print('Quote Data : ')
             print(response.json())
             print('--------')
    else:
    # Handle any errors
            print('Request failed with status code:', response.status_code)
            print(response.json()['errors'][0]['message'])
            data = None
        
funf()

https://api.upstox.com/v2/market-quote/quotes?instrument_key=NSE_EQ|INE029A01011
{“status”:“error”,“errors”:}

@Sri To receive market quotes, ensure you include the necessary header and access token. Here’s an example of a curl request:

curl --location 'https://api.upstox.com/v2/market-quote/quotes?instrument_key=NSE_EQ%7CINE029A01011' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'

For a more detailed explanation and examples, please check out the API Documentation and Example Codes.

@Ketan It was working fine until yesterday and getting this error since morning.
Tried to regenerate the code & Token few times but the error remains.

@Sri Can you share your curl request

@Ketan Hv figured out the issue, Thers a typo in the curl. Please ignore.
Thanks.

Wrong instrument keys given in complete.json.gz file for index option. Last time it was .csv files having issue of non-updation and now have issues with json where data exists but is erroneous. Please inform which file to use .csv or .json.

{"weekly":true,"segment":"NSE_FO","name":"NIFTY","exchange":"NSE","expiry":1712773799000,"instrument_type":"CE","asset_symbol":"NIFTY","underlying_symbol":"NIFTY","instrument_key":*"NSE_FO|39050*","lot_size":50,"freeze_quantity":1800.0,"exchange_token":"39050","minimum_lot":50,"asset_key":"NSE_INDEX|Nifty 50","underlying_key":"NSE_INDEX|Nifty 50","tick_size":5.0,"asset_type":"INDEX","underlying_type":"INDEX","trading_symbol":"NIFTY 22700 CE 10 APR 24","strike_price":22700.0}

As per documentation :

  • Use Instruments data in JSON format instead of CSV, as its structure has been designed for enhanced robustness and future scalability, making programmatic processing easier.

Can someone let me know why are there issues with instrument files and which one to rely upon?

complete.json.gz file ok for today and code working. It is imperative that Upstox developer team clarifies which instrument details file ( csv or json) is monitored and updated regularly so that the issue does not arise in future.