Kite.quote throws error when I send a list of instruments but works when I iterate through the list.

healthsecure15
Hi,

Number of instruments: 498, these are in a list.

When I do:
try:
kite.quote(list_of_instruments)
except Exception as e:
print(e)
kiteconnect.exceptions.DataException: Unknown Content-Type (text/html) with response: (b'

400 Bad request

\nYour browser sent an invalid request.\n\n')
If I do:
count = 0
for i in list_of_instruments:
try:
z = kite.quote(i)
count+=1
print(count)
except Exception as e:
print(e)
print(f'\n\n\n{i}')
No error.

If I understand correctly upto 500 instruments can be requested in a list. Please let me know what the error is about.

TIA
Tagged:
  • rakeshr
    400 Bad request
    Are you sure, you are passing kite.quote(list_of_instruments) list here of instruments in proper string format with proper comma separator?
    Eg: list_of_instruments = ["NSE:SBIN", "BSE:ONGC", ....]
  • healthsecure15
    healthsecure15 edited June 2022
    @rakeshr absolutely sure, I am using the same list in the second for i in list_of_instruments..... test code.

    Here is the list, just in case:
    <pre class="CodeBlock"><code>chunk = 

    ['NFO:BANKNIFTY22JUN33200CE', 'NFO:BANKNIFTY22JUN33300CE', 'NFO:BANKNIFTY22JUN33400CE', 'NFO:BANKNIFTY22JUN33500CE', 'NFO:BANKNIFTY22JUN33600CE', 'NFO:BANKNIFTY22JUN33700CE', 'NFO:BANKNIFTY22JUN33800CE', 'NFO:BANKNIFTY22JUN33900CE', 'NFO:BANKNIFTY22JUN34000CE', 'NFO:BANKNIFTY22JUN34100CE', 'NFO:BANKNIFTY22JUN34200CE', 'NFO:BANKNIFTY22JUN34300CE', 'NFO:BANKNIFTY22JUN34400CE', 'NFO:BANKNIFTY22JUN34500CE', 'NFO:BANKNIFTY22JUN34600CE', 'NFO:BANKNIFTY22JUN34700CE', 'NFO:BANKNIFTY22JUN34800CE', 'NFO:BANKNIFTY22JUN34900CE', 'NFO:BANKNIFTY22JUN35000CE', 'NFO:BANKNIFTY22JUN35100CE', 'NFO:BANKNIFTY22JUN35200CE', 'NFO:BANKNIFTY22JUN35300CE', 'NFO:BANKNIFTY22JUN35400CE', 'NFO:BANKNIFTY22JUN35500CE', 'NFO:BANKNIFTY22JUN35600CE', 'NFO:BANKNIFTY22JUN35700CE', 'NFO:BANKNIFTY22JUN35800CE', 'NFO:BANKNIFTY22JUN35900CE', 'NFO:BANKNIFTY22JUN36000CE', 'NFO:BANKNIFTY22JUN36100CE', 'NFO:BANKNIFTY22JUN36200CE', 'NFO:BANKNIFTY22JUN36300CE', 'NFO:BANKNIFTY22JUN36400CE', 'NFO:BANKNIFTY22JUN36500CE', 'NFO:BANKNIFTY22JUN36600CE', 'NFO:BANKNIFTY22JUN36700CE', 'NFO:BANKNIFTY22JUN36800CE', 'NFO:BANKNIFTY22JUN36900CE', 'NFO:BANKNIFTY22JUN37000CE', 'NFO:BANKNIFTY22JUN37100CE', 'NFO:BANKNIFTY22JUN37200CE', 'NFO:BANKNIFTY22JUN37300CE', 'NFO:BANKNIFTY22JUN37400CE', 'NFO:BANKNIFTY22JUN37500CE', 'NFO:BANKNIFTY22JUN37600CE', 'NFO:BANKNIFTY22JUN37700CE', 'NFO:BANKNIFTY22JUN37800CE', 'NFO:BANKNIFTY22JUN37900CE', 'NFO:BANKNIFTY22JUN38000CE', 'NFO:BANKNIFTY22JUN38100CE', 'NFO:BANKNIFTY22JUN38200CE', 'NFO:BANKNIFTY22JUN38300CE', 'NFO:BANKNIFTY22JUN38400CE', 'NFO:BANKNIFTY22JUN38500CE', 'NFO:BANKNIFTY22JUN38600CE', 'NFO:BANKNIFTY22JUN38700CE', 'NFO:BANKNIFTY22JUN38800CE', 'NFO:BANKNIFTY22JUN38900CE', 'NFO:BANKNIFTY22JUN39000CE', 'NFO:BANKNIFTY22JUN39100CE', 'NFO:BANKNIFTY22JUN39200CE', 'NFO:BANKNIFTY22JUN39300CE', 'NFO:BANKNIFTY22JUN39400CE', 'NFO:BANKNIFTY22JUN39500CE', 'NFO:BANKNIFTY22JUN39600CE', 'NFO:BANKNIFTY22JUN39700CE', 'NFO:BANKNIFTY22JUN39800CE', 'NFO:BANKNIFTY22JUN39900CE', 'NFO:BANKNIFTY22JUN40000CE', 'NFO:BANKNIFTY22JUN40100CE', 'NFO:BANKNIFTY22JUN40200CE', 'NFO:BANKNIFTY22JUN40300CE', 'NFO:BANKNIFTY22JUN40400CE', 'NFO:BANKNIFTY22JUN40500CE', 'NFO:BANKNIFTY22JUN40600CE', 'NFO:BANKNIFTY22JUN40700CE', 'NFO:BANKNIFTY22JUN40800CE', 'NFO:BANKNIFTY22JUN40900CE', 'NFO:BANKNIFTY22JUN41000CE', 'NFO:BANKNIFTY22JUN41100CE', 'NFO:BANKNIFTY22JUN41200CE', 'NFO:BANKNIFTY22JUN41300CE', 'NFO:BANKNIFTY22JUN41400CE', 'NFO:BANKNIFTY22JUN41500CE', 'NFO:BANKNIFTY22JUN41600CE', 'NFO:BANKNIFTY22JUN41700CE', 'NFO:BANKNIFTY22JUN41800CE', 'NFO:BANKNIFTY22JUN41900CE', 'NFO:BANKNIFTY22JUN42000CE', 'NFO:BANKNIFTY22JUN42100CE', 'NFO:BANKNIFTY22JUN42200CE', 'NFO:BANKNIFTY22JUN42300CE', 'NFO:BANKNIFTY22JUN42400CE', 'NFO:BANKNIFTY22JUN42500CE', 'NFO:BANKNIFTY22JUN42600CE', 'NFO:BANKNIFTY22JUN43500CE', 'NFO:BANKNIFTY22JUN45000CE', 'NFO:BANKNIFTY22JUN46500CE', 'NFO:BANKNIFTY2262333200CE', 'NFO:BANKNIFTY2262333300CE', 'NFO:BANKNIFTY2262333400CE', 'NFO:BANKNIFTY2262333500CE', 'NFO:BANKNIFTY2262333600CE', 'NFO:BANKNIFTY2262333700CE', 'NFO:BANKNIFTY2262333800CE', 'NFO:BANKNIFTY2262333900CE', 'NFO:BANKNIFTY2262334000CE', 'NFO:BANKNIFTY2262334100CE', 'NFO:BANKNIFTY2262334200CE', 'NFO:BANKNIFTY2262334300CE', 'NFO:BANKNIFTY2262334400CE', 'NFO:BANKNIFTY2262334500CE', 'NFO:BANKNIFTY2262334600CE', 'NFO:BANKNIFTY2262334700CE', 'NFO:BANKNIFTY2262334800CE', 'NFO:BANKNIFTY2262334900CE', 'NFO:BANKNIFTY2262335000CE', 'NFO:BANKNIFTY2262335100CE', 'NFO:BANKNIFTY2262335200CE', 'NFO:BANKNIFTY2262335300CE', 'NFO:BANKNIFTY2262335400CE', 'NFO:BANKNIFTY2262335500CE', 'NFO:BANKNIFTY2262335600CE', 'NFO:BANKNIFTY2262335700CE', 'NFO:BANKNIFTY2262335800CE', 'NFO:BANKNIFTY2262335900CE', 'NFO:BANKNIFTY2262336000CE', 'NFO:BANKNIFTY2262336100CE', 'NFO:BANKNIFTY2262336200CE', 'NFO:BANKNIFTY2262336300CE', 'NFO:BANKNIFTY2262336400CE', 'NFO:BANKNIFTY2262336500CE', 'NFO:BANKNIFTY2262336600CE', 'NFO:BANKNIFTY2262336700CE', 'NFO:BANKNIFTY2262336800CE', 'NFO:BANKNIFTY2262336900CE', 'NFO:BANKNIFTY2262337000CE', 'NFO:BANKNIFTY2262337100CE', 'NFO:BANKNIFTY2262337200CE', 'NFO:BANKNIFTY2262337300CE', 'NFO:BANKNIFTY2262337400CE', 'NFO:BANKNIFTY2262337500CE', 'NFO:BANKNIFTY2262337600CE', 'NFO:BANKNIFTY2262337700CE', 'NFO:BANKNIFTY2262337800CE', 'NFO:BANKNIFTY2262337900CE', 'NFO:BANKNIFTY2262338000CE', 'NFO:BANKNIFTY2262338100CE', 'NFO:BANKNIFTY2262338200CE', 'NFO:BANKNIFTY2262338300CE', 'NFO:BANKNIFTY2262338400CE', 'NFO:BANKNIFTY2262338500CE', 'NFO:BANKNIFTY2262338600CE', 'NFO:BANKNIFTY2262338700CE', 'NFO:BANKNIFTY2262338800CE', 'NFO:BANKNIFTY2262338900CE', 'NFO:BANKNIFTY2262339000CE', 'NFO:BANKNIFTY2262339100CE', 'NFO:BANKNIFTY2262339200CE', 'NFO:BANKNIFTY2262339300CE', 'NFO:BANKNIFTY2262339400CE', 'NFO:BANKNIFTY2262339500CE', 'NFO:BANKNIFTY2262339600CE', 'NFO:BANKNIFTY2262339700CE', 'NFO:BANKNIFTY2262339800CE', 'NFO:BANKNIFTY22JUL33200CE', 'NFO:BANKNIFTY22JUL33300CE', 'NFO:BANKNIFTY22JUL33400CE', 'NFO:BANKNIFTY22JUL33500CE', 'NFO:BANKNIFTY22JUL33600CE', 'NFO:BANKNIFTY22JUL33700CE', 'NFO:BANKNIFTY22JUL33800CE', 'NFO:BANKNIFTY22JUL33900CE', 'NFO:BANKNIFTY22JUL34000CE', 'NFO:BANKNIFTY22JUL34100CE', 'NFO:BANKNIFTY22JUL34200CE', 'NFO:BANKNIFTY22JUL34300CE', 'NFO:BANKNIFTY22JUL34400CE', 'NFO:BANKNIFTY22JUL34500CE', 'NFO:BANKNIFTY22JUL34600CE', 'NFO:BANKNIFTY22JUL34700CE', 'NFO:BANKNIFTY22JUL34800CE', 'NFO:BANKNIFTY22JUL34900CE', 'NFO:BANKNIFTY22JUL35000CE', 'NFO:BANKNIFTY22JUL35100CE', 'NFO:BANKNIFTY22JUL35200CE', 'NFO:BANKNIFTY22JUL35300CE', 'NFO:BANKNIFTY22JUL35400CE', 'NFO:BANKNIFTY22JUL35500CE', 'NFO:BANKNIFTY22JUL35600CE', 'NFO:BANKNIFTY22JUL35700CE', 'NFO:BANKNIFTY22JUL35800CE', 'NFO:BANKNIFTY22JUL35900CE', 'NFO:BANKNIFTY22JUL36000CE', 'NFO:BANKNIFTY22JUL36100CE', 'NFO:BANKNIFTY22JUL36200CE', 'NFO:BANKNIFTY22JUL36300CE', 'NFO:BANKNIFTY22JUL36400CE', 'NFO:BANKNIFTY22JUL36500CE', 'NFO:BANKNIFTY22JUL36600CE', 'NFO:BANKNIFTY22JUL36700CE', 'NFO:BANKNIFTY22JUL36800CE', 'NFO:BANKNIFTY22JUL36900CE', 'NFO:BANKNIFTY22JUL37000CE', 'NFO:BANKNIFTY22JUL37100CE', 'NFO:BANKNIFTY22JUL37200CE', 'NFO:BANKNIFTY22JUL37300CE', 'NFO:BANKNIFTY22JUL37400CE', 'NFO:BANKNIFTY22JUL37500CE', 'NFO:BANKNIFTY22JUL37600CE', 'NFO:BANKNIFTY22JUL37700CE', 'NFO:BANKNIFTY22JUL37800CE', 'NFO:BANKNIFTY22JUL37900CE', 'NFO:BANKNIFTY22JUL38000CE', 'NFO:BANKNIFTY22JUL38100CE', 'NFO:BANKNIFTY22JUL38200CE', 'NFO:BANKNIFTY22JUL38300CE', 'NFO:BANKNIFTY22JUL38400CE', 'NFO:BANKNIFTY22JUL38500CE', 'NFO:BANKNIFTY22JUL38600CE', 'NFO:BANKNIFTY22JUL38700CE', 'NFO:BANKNIFTY22JUL38800CE', 'NFO:BANKNIFTY22JUL38900CE', 'NFO:BANKNIFTY22JUL39000CE', 'NFO:BANKNIFTY22JUL39100CE', 'NFO:BANKNIFTY22JUL39200CE', 'NFO:BANKNIFTY22JUL39300CE', 'NFO:BANKNIFTY22JUL39400CE', 'NFO:BANKNIFTY22JUL39500CE', 'NFO:BANKNIFTY22JUL39600CE', 'NFO:BANKNIFTY22JUL39700CE', 'NFO:BANKNIFTY22JUL39800CE', 'NFO:BANKNIFTY22JUL39900CE', 'NFO:BANKNIFTY22JUL40000CE', 'NFO:BANKNIFTY22JUL40100CE', 'NFO:BANKNIFTY22JUL40200CE', 'NFO:BANKNIFTY22JUL40300CE', 'NFO:BANKNIFTY22JUL40400CE', 'NFO:BANKNIFTY2270733200CE', 'NFO:BANKNIFTY2270733300CE', 'NFO:BANKNIFTY2270733400CE', 'NFO:BANKNIFTY2270733500CE', 'NFO:BANKNIFTY2270733600CE', 'NFO:BANKNIFTY2270733700CE', 'NFO:BANKNIFTY2270733800CE', 'NFO:BANKNIFTY2270733900CE', 'NFO:BANKNIFTY2270734000CE', 'NFO:BANKNIFTY2270734100CE', 'NFO:BANKNIFTY2270734200CE', 'NFO:BANKNIFTY2270734300CE', 'NFO:BANKNIFTY2270734400CE', 'NFO:BANKNIFTY2270734500CE', 'NFO:BANKNIFTY2270734600CE', 'NFO:BANKNIFTY2270734700CE', 'NFO:BANKNIFTY2270734800CE', 'NFO:BANKNIFTY2270734900CE', 'NFO:BANKNIFTY2270735000CE', 'NFO:BANKNIFTY2270735100CE', 'NFO:BANKNIFTY2270735200CE', 'NFO:BANKNIFTY2270735300CE', 'NFO:BANKNIFTY2270735400CE',
  • healthsecure15
    @rakeshr strange when I reduce the number of instruments to 400 in 1 list. It has no issues. I think I read in the documentation that upto 500 instruments at a time is not an issue. Please clarify?
  • sujith
    @healthsecure15,
    It could be because length of param is too long. You can try using only instrument tokens that will reduce the payload length.
Sign In or Register to comment.