Skip to content Skip to sidebar Skip to footer

Weather Undground Api Call Limit Per Minute

I have to limit my API request to 10 calls per minute, how can I modify the for loops to accomplish this? I am trying to add in time.sleep(8) in the for observation loop without an

Solution 1:

A possible explanation of why you are still exceeding the API limit might have to do with the line on which you are adding the time wait. If the API response you are getting contains no observations, the inner loop won't execute. So first I would try to move the time wait in the outer loop right after the API call.

You might also consider using something like loopingCall from twisted to schedule your task to run every X seconds http://twistedmatrix.com/documents/9.0.0/core/howto/time.html

Solution 2:

Depending on how realtime you want your data or you can afford to be a day behind, you could get all observations for a date in the past which would be one API call to retrieve data for a day(or it could be an end of day summary for the current day's observations).

Alternatively, if you're trying to get the current weather every x minutes or so (under the limit) I'd use some sort of loop with a timer (or possibly twisted which seems to abstract the "loop") but make a call to one of the following (depending on what you're looking for). Your current code is looking for dates in the past but these other endpoints are for the current day.

You don't want the timer in the observations loop since, as mentioned above, there might be none.

http://wunderweather.readthedocs.io/en/latest/WunderWeather.html#WunderWeather.weather.Extract.hourly_daycast

http://wunderweather.readthedocs.io/en/latest/WunderWeather.html#WunderWeather.weather.Extract.today_now

which can be called similar to the following examples http://wunderweather.readthedocs.io/en/latest/index.html#additional-examples

Post a Comment for "Weather Undground Api Call Limit Per Minute"