kiteconnect.exceptions.NetworkException: Too many requests

karthik_mudaliar
I have recently started using your API n was getting this network issue again n again
I tried checking out the Kite Connect Developer Forum & it didn't help this time

Error that I get
Banknifty Open Price: 43400 Fri May 12 09:38:00 2023
CE Option New High Price: 730 Fri May 12 09:38:01 2023
Traceback (most recent call last):
File "/Users/karthikmudaliar/Desktop/Triangle_Code/Main_run.py", line 43, in
ce1_ltp = kite.quote(ce1)[ce1]['ohlc']["high"]
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kiteconnect/connect.py", line 581, in quote
data = self._get("market.quote", params={"i": ins})
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kiteconnect/connect.py", line 851, in _get
return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/kiteconnect/connect.py", line 927, in _request
raise exp(data["message"], code=r.status_code)
kiteconnect.exceptions.NetworkException: Too many requests


My Code
from kiteconnect import KiteConnect
import pandas as pd
import datetime
import time

api_key = "ak"
api_secret = "as"
access_token = "at"

kite = KiteConnect(api_key)
kite.set_access_token(access_token)

#Fetching BNF LTP & rounding off
bnf = kite.ltp('NSE', '260105')
bnf_ltp = bnf['260105']['last_price']
bnf_final = int(round(bnf_ltp, -2))
print(f"Banknifty Open Price: {bnf_final}", time.ctime())

# Set idle time
start_idle = datetime.time(hour=00, minute=25)
end_idle = datetime.time(hour=9, minute=16)

# Set the time range to save the high and low prices
start_time = datetime.time(hour=9, minute=16)
end_time = datetime.time(hour=10, minute=30)


#CE 500
ce1_high = 0


# Loop to save high prices
while True:
now = datetime.datetime.now().time()
if now >= start_idle and now < end_idle:
print("IDLE", time.ctime())
time.sleep(10)
elif now >= end_idle:
while True:
now = datetime.datetime.now().time()
ce1 = 'NFO:BANKNIFTY23518'+str(bnf_final-500)+'CE'
if now >= start_time and now <= end_time:
ce1_ltp = kite.quote(ce1)[ce1]['ohlc']["high"]
if ce1_ltp > ce1_high:
ce1_high = ce1_ltp
print(f"CE Option New High Price: {ce1_high}", time.ctime())
time.sleep(1)
elif now > end_time:
print(f"Saving high price loop closed {ce1_high}", time.ctime())
break
break
  • rakeshr
    kiteconnect.exceptions.NetworkException: Too many requests
    Make sure, you are not exceeding the rate limits defined here.
Sign In or Register to comment.