Greetings FA crew,
I am trying to get flight schedules from a 2 hour period and pulling a maximum of 9 pages per API request.
Here is my code:
airport = apt
print(airport,orighours[tm])
payload = {'start': start,'end': end,'type':'Airline','max_pages': 9}
auth_header = {'x-apikey':key}
apiUrl = "https://aeroapi.flightaware.com/aeroapi/"
response = requests.get(apiUrl + f"airports/{airport}/flights/scheduled_departures",
params=payload, headers=auth_header)
if response.status_code == 200:
#print(response.json())
print("Got flights")
else:
print(response.json())
print("Error executing request")
print("Pausing for 60 seconds")
time.sleep(61)
I am limited to 10sets/min with the free plan.
So in my code I am pulling 9 pages and then telling the code to sleep for 61 seconds.
But eventually after about 5 requests I get this error:
{‘title’: ‘Rate limit error’, ‘reason’: ‘RATE_LIMIT_ERROR’, ‘detail’: ‘User has reached quota limit’, ‘status’: 429}
I know that my code is actually pausing for 61 seconds between requests so I am confused as to what is going on…
Thanks for the help!