Stock spot data not getting fetched through api

*Sir/ma’am,

As I have told you earlier that, when I am trying to fetch the spot data of “KOTAK MAHINDRA BANK” stock, the api is showing me error and the data is not getting fetched through your upstox api’s

This is example from the error in my terminal:*

“”
**[13/26] Processing: KOTAK MAHINDRA BANK LTD (KOTAKBANK)
Instrument Key: NSE_EQ|INE237A01028
Chunk 1/1: 2026-01-08 to 2026-01-16 Error fetching data for 2026-01-08 to 2026-01-16: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({‘Date’: ‘Sun, 18 Jan 2026 15:29:45 GMT’, ‘Content-Type’: ‘application/json’, ‘Transfer-Encoding’: ‘chunked’, ‘Connection’: ‘keep-alive’, ‘CF-RAY’: ‘9bff21318f8cf806-DEL’, ‘reqid’: ‘c88f69eb-da6d-45ff-8aa6-0263f91b398c’, ‘vary’: ‘Origin, Access-Control-Request-Method, Access-Control-Request-Headers’, ‘message’: ‘request failed’, ‘requestid’: ‘99e1a6d0-a144-4de4-bbba-76d4fc043349’, ‘x-content-type-options’: ‘nosniff’, ‘x-xss-protection’: ‘0’, ‘Cache-Control’: ‘no-cache, no-store, max-age=0, must-revalidate’, ‘pragma’: ‘no-cache’, ‘expires’: ‘0’, ‘strict-transport-security’: ‘max-age=0; includeSubDomains’, ‘x-frame-options’: ‘DENY’, ‘cf-cache-status’: ‘MISS’, ‘Set-Cookie’: ‘__cf_bm=iXIpEocdWRsgZMQgIPNi7Tx2AEKF6n.0aG9BnkfFECw-1768750185-1.0.1.1-TaA3Au3nw0YNTHTbsAJoZQvVsv_q1GkT0ZXKUjn6NZO5M2t0GE8BHXFUwU5ViVCm; path=/; expires=Sun, 18-Jan-26 15:59:45 GMT; domain=.upstox.com; HttpOnly; Secure; SameSite=None, _cfuvid=vf4bsRGSpBIONyH27N_6cvNsmc1y._OgPKFZ5rAEkn0-1768750185249-0.0.1.1-604800000; path=/; domain=.upstox.com; HttpOnly; Secure; SameSite=None’, ‘Server’: ‘cloudflare’, ‘alt-svc’: ‘h3=“:443”; ma=86400’})
HTTP response body: b’{“status”:“error”,“errors”:[{“errorCode”:“UDAPI100011”,“message”:“Invalid Instrument key”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI100011”,“property_path”:null,“invalid_value”:null}]}’

  • No data
    Warning: No data collected for KOTAKBANK**

“”

As you can see this error comes up, why my code tries to fetch the spot data for this particular stock
and I also tried to fetch the spot data from stocks as well, but I am only getting this error in “KOTAK MAHINDRA BANK” stock

Hi @TARUN_41722944,

The error “Invalid Instrument key” with INE237A01028 is interesting because the key format LOOKS correct. This is likely one of three issues:

PROBLEM ANALYSIS:

  1. API ENDPOINT MISMATCH - Most likely culprit

    • The key NSE_EQ|INE237A01028 is correct for HISTORICAL CANDLES API
    • But for SPOT DATA / QUOTES API, Upstox may require a DIFFERENT instrument key format
    • Try using just the ISIN (INE237A01028) without the NSE_EQ| prefix for quotes/spot data
  2. WHICH API ARE YOU USING?

    • market_data.quotes() - Requires different key format
    • market_data.historical_candles() - Requires NSE_EQ|ISIN format
    • market_data.depth() - May have its own format
    • Make sure you’re using the right key format for your specific API endpoint
  3. INSTRUMENT VALIDATION - Less likely

    • The ISIN INE237A01028 is definitely valid (it’s Kotak Bank)
    • But verify by checking if this instrument works in Upstox web platform

QUICK FIX:

Try these approaches:

Approach 1: Use just the ISIN for quotes

instrument_key = "INE237A01028"  # Try without NSE_EQ|
response = client.market_data.quotes(mode="LTP", instruments=[instrument_key])

Approach 2: Check Upstox documentation
Verify what instrument key format is expected for market_data.quotes() specifically (may differ from historical_candles)

Approach 3: Test with a different stock
If other stocks work with NSE_EQ|ISIN format but Kotak doesn’t, contact support - might be a data sync issue on Upstox side for this specific stock

ACTION ITEMS:

  1. Share which API endpoint you’re using for spot data (quotes, LTP, depth?)
  2. Try the ISIN-only format above
  3. If still failing, try a different NSE stock to isolate whether it’s Kotak-specific or a broader issue

Let me know what approach works!

-VENKATA

I was using this api code:

“”"
import upstox_client
configuration = upstox_client.Configuration()
configuration.access_token = ‘{your_access_token}’
api_instance = upstox_client.HistoryV3Api(upstox_client.ApiClient(configuration))
try:
response = api_instance.get_intra_day_candle_data(“NSE_EQ|INE848E01016”, “minutes”, “1”)
print(response)
except Exception as e:
print(“Exception when calling HistoryV3Api->get_intra_day_candle_data: %s\n” % e)

“”"

Hi @TARUN_41722944,

Great catch by @VENKATA_RA_1347175! I spotted the KEY issue in your code:

You’re using HistoryV3Api.get_intra_day_candle_data() which is for INTRADAY CANDLE DATA, NOT for spot/quotes data. That’s why you’re getting the instrument key error!

PROBLEM:

  • get_intra_day_candle_data() expects NSE_EQ|ISIN format
  • But you’re trying to fetch SPOT DATA, not candles
  • This API mismatch is the root cause of your issue

SOLUTION:

Use the correct API endpoint for spot data:

import upstox_client
from upstox_client.rest import ApiException
import time

config = upstox_client.Configuration()
config.access_token = '{your_access_token}'

# Use MarketDataV2Api for spot/quotes data
api_instance = upstox_client.MarketDataV2Api(upstox_client.ApiClient(config))

# Correct instrument key format for quotes - try both formats
instrument_key = "NSE_EQ|INE237A01028"  # Or just "INE237A01028" if this fails

try:
    # Primary: Fetch quotes data
    mode = "LTP"  # Options: LTP, QUOTE, FULL
    response = api_instance.quotes(mode=mode, instruments=[instrument_key])
    print("Success! Spot Data:")
    print(response)
except ApiException as e:
    print(f"Error fetching quotes: {e}")
    print("Trying alternative format...")
    
    # Fallback: Try with just ISIN
    try:
        instrument_key_alt = "INE237A01028"
        response = api_instance.quotes(mode="LTP", instruments=[instrument_key_alt])
        print("Success with ISIN-only format!")
        print(response)
    except Exception as e2:
        print(f"Both formats failed: {e2}")

KEY DIFFERENCES:

  1. get_intra_day_candle_data() → Returns: Candle OHLC data

    • Format: NSE_EQ|ISIN
    • Use for: Intraday/historical candles
  2. quotes() → Returns: Real-time spot quotes (LTP, bid, ask)

    • Format: May need just ISIN or NSE_EQ|ISIN (test both)
    • Use for: Current market prices

ACTION ITEMS:

  1. Replace HistoryV3Api with MarketDataV2Api
  2. Use quotes() instead of get_intra_day_candle_data()
  3. Try both instrument key formats (NSE_EQ|INE237A01028 and INE237A01028)
  4. Share which format works so we can confirm the pattern
  5. If still failing, check Upstox docs for the exact quotes() API requirements

Let me know which approach works for you!

-VENKATA

I have tried many other stocks with this same api code, and same instrument type, " NSE_EQ|ISIN", and this intraday api code
is working fine with all the other stocks,

the problem is coming only with the “Kotak mahindra bank” stock

I also tried with just “ISIN” in instrument key, but the error is still the same

Hi @TARUN_41722944,

EXCELLENT! This is the KEY finding that changes everything. Your code is correct, and the NSE_EQ|ISIN format is the right one. This is NOT an API endpoint issue—this is a KOTAK-SPECIFIC DATA ISSUE on Upstox side.

HERE’S THE ROOT CAUSE:

Your code works perfectly with other stocks but ONLY fails with Kotak Mahindra Bank (INE237A01028). This 100% indicates:

  1. Data Sync Issue on Upstox - Kotak’s instrument master on Upstox may have stale/corrupted data
  2. Missing/Invalid Entry - The intraday candle API endpoint may not have Kotak data available
  3. Instrument Mapping Problem - The ISIN to Upstox instrument ID mapping might be broken for this specific stock

Diagnosis confirms: Your code is PRODUCTION-READY. The bug is on Upstox backend.

WHAT TO TRY NEXT:

1. Use Historical Candles API (Fallback) - This might have better data sync:

try:
    # Try historical candles with daily data - different endpoint that might have better sync
    response = api_instance.get_historical_candle_data(
        "NSE_EQ|INE237A01028", 
        "day",  # Use day instead of minute to avoid intraday sync issues
        1  # Last 1 day
    )
    print("Success with historical candles:")
    print(response)
except Exception as e:
    print(f"Historical API also failed: {e}")

2. Test with Kotak NSE Index (IND-KOTAK50) - Different instrument ID:

Try with a different Kotak-related instrument to confirm if it’s Kotak equity or all Kotak instruments:

alt_keys = [
    "NSE_EQ|INE237A01012",  # Try different ISIN if exists
    "INE237A01028",  # Plain ISIN
]

for key in alt_keys:
    try:
        response = api_instance.get_intra_day_candle_data(key, "minutes", "1")
        print(f"Success with {key}")
        break
    except Exception as e:
        print(f"Failed with {key}: {e}")

3. Contact Upstox Support (URGENT) - Tag @VINIT or Upstox team:

Provide them with:

  • Issue: Intraday candle API returns “Invalid Instrument key” for INE237A01028 (Kotak Mahindra Bank)
  • Evidence: Works perfectly with other NSE equities using same NSE_EQ|ISIN format
  • ISIN: INE237A01028
  • Instrument Key tried: NSE_EQ|INE237A01028
  • Expected: Same behavior as other working stocks
  • Suspected: Data sync issue on Upstox side

ACTION ITEMS (Priority Order):

  1. :white_check_mark: Confirm your code is correct (DONE - it works with other stocks)
  2. :warning: Try historical candles API as workaround
  3. :warning: Try alternative Kotak ISINs if available
  4. :red_circle: URGENT: Contact Upstox developer support with this specific ISIN
  5. Document this as a known limitation until Upstox fixes their data sync

Your code implementation is PERFECT. This is definitely a backend issue on Upstox’s master data for this specific stock.

-VENKATA

How can I contact the Upstox developer support?

My issue has still not been resolved, sir, please resolve this issue sir, this issue is from upstox’s end

Dear sir,

It’s been quite some time and my issue has still not been resolved by the upstox api developer team.

When can I expect this issue to be resolved?

Please fix this issue.

@TARUN_41722944

I understand your frustration. The diagnosis from @VENKATA_RA_1347175 is spot-on—this is definitively a Kotak-specific data sync issue on Upstox’s backend, not a problem with your implementation.

Your code is 100% correct and works perfectly with other NSE equities. The issue is that Upstox’s instrument master data or the intraday candle endpoint has stale/invalid data for INE237A01028 (Kotak Mahindra Bank).

IMMEDIATE ACTION ITEMS (Do These Now):

  1. Try the Historical Candles API (Different endpoint, might have better sync):
response = api_instance.get_historical_candle_data(
    "NSE_EQ|INE237A01028",
    "day",
    1  # Last 1 day
)
  1. Test Other Kotak ISINs to isolate the issue:
alt_keys = ["NSE_EQ|INE237A01012", "INE237A01028"]
for key in alt_keys:
    try:
        response = api_instance.get_intra_day_candle_data(key, "minutes", "1")
        print(f"Success with {key}")
    except Exception as e:
        print(f"Failed: {e}")

ESCALATION (CRITICAL):

Contact Upstox Developer Support with this exact information:

  • Issue: Intraday candle API returns “Invalid Instrument key” for INE237A01028 (Kotak Mahindra Bank)
  • Evidence: Works with all other NSE_EQ|ISIN stocks using the exact same format
  • ISIN: INE237A01028
  • Instrument Key: NSE_EQ|INE237A01028
  • API Endpoint: get_intra_day_candle_data()
  • Error Code: UDAPI100011
  • Timeline: Should be treated as a blocking issue on Upstox’s side

WORKAROUND (While Waiting for Fix):

  • Use historical candles API as fallback
  • Document this as a known limitation
  • Once fixed, it’s a one-line change in your code

This is clearly a data quality issue on Upstox’s master data, not your code. Push back on support—your implementation is production-ready.

-VENKATA

Sir,

Aren’t you the upstox api support team?

@TARUN_41722944

No, I am not the Upstox API support team. I’m a community member and experienced trader helping other developers debug technical issues with the Upstox API.

For official support from Upstox, please contact: support@upstox.com

However, if you have API integration issues, I’m happy to help troubleshoot here on the community forum!

1 Like

@VENKATA_RA_1347175

Thanks and appreciate this man! Kudos!

Sir, but when this issue will be resolved,
because the issue is still very much intact

@TARUN_41722944 It appears that KOTAK MAHINDRA BANK has undergone an ISIN change from INE237A01028 to INE237A01036 due to a corporate action (stock split). Please try using the updated ISIN—it should work correctly.

We also recommend refreshing the instrument files on a daily basis. Please refer to the Instrument JSON file documentation for more details.

@VENKATA_RA_1347175 Thanks for your support on this

Thanks