How to deal with rate limit of API calls

Hi, I am just getting started with bolt. In my application I have to read the status of the GPIO-Input pin for every one second and if there is any change in status I have to say glow an LED.

I am using python to program for the same and everything worked well until I came to know about the API rate limit. My program stopped working and I got the following mail.

Hi,

Unfortunately, we have to rate limit your API access due to a large number of requests received from your account.

You have crossed the allowed threshold of 200 hits in last 6 minute(s).

API requests for your account will be enabled in next: 6 Hours:0 Minutes:0 Seconds

Now how am I suppose to deal with it? Is there another way to check the status of the Input pin without using the API call using python script? Please guide me on this.

Thanks.

Hi @mailtoaswinth,

Please go through the following docs page to know how the Bolt Cloud decides whether your API has to be rate limited or not.

You can then decide on a polling frequency which would not get rate limited by the system.

I would suggest using the API call once every 2 seconds. This speed is neither too slow for your purpose, nor is it so fast that the Bolt Cloud will limit the calls.

Also, with this rate, of polling you will still have the ability to use the API calls for other non-polling related requirements.

Hey there!
There are some terms and conditions for using these api’s specially the ones that are free.
To maintain integrity and to make sure that it is being used fairly.
Since your rates are limited there’s nothing you can do atleast with that API.

For an alternative you can simply reset your api by simply generating a new one.
REMEMBER to change the API in your project.

1 Like

@ mailtoaswinth Even i received this error while performing an LED blink experiment. I suppose the API rate has been limited as there had been too many request loads within a very short span of time. A good approach would be to make the program control sleep for a fixed amount of time and then make it resume back again. Please refer the below code :

import time
time.sleep(n)

where, ‘n’ can be time in seconds.
I guess this simple approach could solve the problem that you are facing. But if you are still facing the same issue, i would like you to refer the solution here : https://docs.boltiot.com/docs/api-access-rules.
I hope this helps.

I also received this error while making my project. API rates have been limited for example 20 hits in 1 min. You can add time.sleep(10) for a fixed amount of time. This will pause the program every 10 seconds.
This will solve the problem, it did mine.

1 Like