API access blocked

Please unblock my API access, I’m working on project which sent 5 requests and access has been blocked.


Ankur Tripathi

Sent from my BlackBerry - the most secure mobile device


Could you share the code that you used for this code?
It might help us understand how or why you hit the rate limit so fast.

#import the necessary libraries
from boltiot import Bolt, Sms
import json, time, math, statistics

#store all credentials related to Twilio and Bolt within double quotes
sid = “” # sid given on Twilio dashboard
auth_token = “” # authorization token given on Twilio dashboard
From = “” #phone number given by Twilio
To = “” #your mobile number that receives notification
a = “” # your api_key given on Bolt Cloud dashboard
d = “” # your device_id given on Bolt Cloud dashboard

maxim = 400 #probable analog equivalent of temperature at which fire starts
frame_size = 10 #used for Z-score analysis
mul_factor = 10 #used for Z-score analysis

mb = Bolt(a,d) #create object of Bolt class
sms = Sms(sid,auth_token,From,To) #create object of Sms class
prev_data=[] #stores sensor values

#function to calculate bounds for the temperature sensor using Z-score
def cal_bounds(prev_data,frame_size,mul_factor):
#check if enough data is collected for calculation of Z-score
if len(prev_data)<frame_size :
return None
#deletion of older data
if len(prev_data)>frame_size :
del prev_data[0:len(prev_data)-frame_size]
mean=statistics.mean(prev_data) #calculate mean
for i in prev_data :
var+= math.pow((i-mean),2) #calculate variance
Zn = mul_factor * math.sqrt(var/ frame_size) #calculate Z-score
Hb= prev_data[frame_size-1]+Zn #calculate upper bound
Lb = prev_data[frame_size-1]-Zn #calculate lower bound
return [Hb,Lb]

#iterate over a loop to sense temperature in theinterval of 10s
while True:
print("\nReading sensor value")
response = mb.analogRead(‘A0’) #read values of A0 analog pin
data = json.loads(response) #convert json data to python object
if data[‘success’] != 1:
print("Error in the data collected: "+data[‘value’]) #print error
print("Sensor value = "+str(data[‘value’]))
bounds = cal_bounds(prev_data,frame_size,mul_factor) #create object of cal_bounds
s_val = int(data[‘value’])
#check if sensor value exceeds the temperature at which fire starts
if s_val>=maxim:
print(“Starting Alarm!”)
print("Alarm is ON "+mb.digitalWrite(‘0’,‘HIGH’)) #Buzzer rings
print("Alarm is ON "+mb.digitalWrite(‘0’,‘LOW’))
print("Alarm is ON "+mb.digitalWrite(‘0’,‘HIGH’))
print("Alarm is ON "+mb.digitalWrite(‘0’,‘LOW’))
print("Led is ON "+mb.digitalWrite(‘1’,‘HIGH’))
print("Led is ON "+mb.digitalWrite(‘1’,‘LOW’))
print("Led is ON "+mb.digitalWrite(‘1’,‘HIGH’))
sms.send_sms("Sensor value is " + str(s_val)) #send Twilio alert message
print("Alarm is ON "+mb.digitalWrite(‘0’,‘LOW’)) #Buzzer is silent
print("Led is ON "+mb.digitalWrite(‘1’,‘LOW’)) #Led doesn’t glow

#check if enough data has been collected
if not bounds:
  print("Need ",(frame_size-len(prev_data))," more data points for Zscore")
  #check if sensor value is within the bounds computed by Z-score 
  if s_val > bounds[0] :
    print("Temperature increased suddenly")
    #notify anomaly using Twilio
    sms.send_sms("Sensor value increased suddenly to " + str(s_val))
except Exception as e:
  print("Error in detecting anomaly: ",e) #print error

except Exception as e:
print("Error: ",e) #print error

Each of the digitalWrite that you called in your code is worth 1 API call.

After looking at your code and the screenshot that you shared, your API key was blocked on the 20th API call. Please do the calculations and confirm the same.

Because of this your code violated the API rate limit for every minute. You can go through the following link to know the limits available for different time periods.