4

Got hit with a Too Many Requests error whilst using an access token every 10 seconds. On re-reading the docs I realise this is a no-no ("To avoid errors we recommend you make requests at a rate of once per minute or less").

Anyone know how long I'll be limited for?

thesimm
  • 774
  • 3
  • 12

3 Answers3

6

Note: this is the current implementation. It may change.

The requests are counted using a one hour sliding window. If you use all of them in one second you'll need to wait an hour for the first one to drop out of the window.

If you use all of them in a 10 minute window you'll get one more request in 50 minutes, and then more requests over 10 minutes as more drop out of the sliding window.

mccv
  • 386
  • 1
  • 2
  • 7
  • 1
    Thanks for this input - is this an official Nest response, or one based on your own experience? Also, you mention using all your requests within a certain timespan - presumably this is 60 per hour? Having had the opportunity to get Firebase & JSON streaming working, this is no longer such an issue for me, but it is still really useful information to have. – thesimm Jul 16 '14 at 17:10
5

Answering my own question: more than 10 minutes and less than an hour.

At least, that's what I experienced today, although last night was at least an hour before I gave up and got a new token.

Maybe it's being manually cleared by Nest, in which case I suppose that it's as long as a piece of string. Unfortunately, whilst Nest send us here for support, and then don't answer any questions, it's difficult to be sure.

thesimm
  • 774
  • 3
  • 12
0

Given that Nest is recommending that you only make requests once per minute, the error should clear after a minute of inactivity.

The Data Rate Limits guide also states:

As we learn more about client usage patterns and their impact on the service we may find it necessary to modify rate limits. We strongly encourage you to build your clients to use the minimum number of calls required to build a compelling user experience, and to deal with rate limit violations appropriately.

So it sounds like if you need data updates more often than once per minute you should use the REST streaming or Firebase version of the API to avoid a large number of connection events. This will also result in better performance as the HTTP connection does not need to be spun up every time.

David W. Keith
  • 2,246
  • 17
  • 20
  • 1
    It didn't clear after a minute (I'd already tried waiting). In fact it still hadn't cleared after an hour which is why I ended up getting another token. I still think the question is reasonable - How long is the ban imposed for? – thesimm Jun 26 '14 at 18:27
  • 1
    I have now implemented a local cache which prevents the Nest-API being hit more than once every 60 seconds. However, I have just been hit by the 429: Too Many Requests response again, which implies that even every 60 seconds is too frequent. – thesimm Jun 27 '14 at 15:11
  • If the device's battery is low, you will also get a 429 (to prevent the battery from draining) – David W. Keith Jul 26 '14 at 04:01