{'code': 429, 'message': 'request limit reached', 's': 'error'}

I’m encountering an intermittent error when calling the FYERS History API. This problem seems to occur randomly, sometimes appearing and sometimes not. It started happening on March 30th, and prior to that, the same code was functioning correctly.

  • could you please advise if there are any ongoing issues

Error :

{‘code’: 429, ‘message’: ‘request limit reached’, ‘s’: ‘error’}

Thought I’m the only one facing this problem and was debugging my code to figure it out :).

I too faces the issue in the morning, later after 10:00, it started working fine. Look like fyers guys have done some fix.

can you please confim this, We want to trade not keep debuging the code.

Please give a status page where I can see how many API calls I have made and which limit is exceed and when. This will help us a lot.

@shyam.cqj9mxeg you can use below code to keep a track of api hits. It’ll create a new file for a day so that if your code fails, your counts will be loaded and resume from there onwards.

hope this’ll help.

def load_number_from_json():
    file_path = f"call_counts_{get_today_yyyy_mm_dd()}.json"
    # Check if the file already exists
    if not os.path.exists(file_path):
        data = {'number': apiCntr}
        # If the file doesn't exist, create an empty file
        with open(file_path, 'w') as file:
            json.dump(data, file)
            print(f"Empty file '{file_path}' created successfully.")
            return apiCntr
    else:
        with open(file_path, "r") as file:
            data = json.load(file)
            print(f"File '{file_path}' already exists. data = {data}")
            return data.get('number', 0)

def save_number_to_json():
    file_path = f"call_counts_{get_today_yyyy_mm_dd()}.json"
    data = {'number': apiCntr}
    with open(file_path, "w") as file:
        json.dump(data, file)

Thanks Jatin,