thesimm
thesimm

Reputation: 774

Nest API - How long do Per Access Token rate limitations last

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?

Upvotes: 4

Views: 1400

Answers (3)

mccv
mccv

Reputation: 386

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.

Upvotes: 6

thesimm
thesimm

Reputation: 774

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.

Upvotes: 5

David W. Keith
David W. Keith

Reputation: 2254

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.

Upvotes: 0

Related Questions