Am finding that I am getting 429 return error messages for rate limiting when my server sends operational commands to a set of ~5 to 12 notecards. I saw in the docs that there is a 7 messages per minute limitation but would like to clarify if that includes access token requests as well? Also, is the 7 message limit windowed per minute or interval between messages? I can use a library like aiolimiter but it can work in either a fixed message per interval limit or allow a burst of X messages before becoming rate limited. Each device I am sending to has a unique configuration so batch operations would not be helpful. Having to wait several minutes to send configuration commands to a dozen devices is a definite usability concern and would like to figure out the best way to manage it especially since the traffic is a burst of operational updates and then no API calls for hours or days.
Hi @szygmunt,
To answer your very first question, the API token requests are excluded from the rate limitation policy.
The rate limitation rules are set to 7 requests per minute and windowed per minute.
The current limit has been defined based on our research of user needs and is aimed primarily at encouraging our users to follow the good practices of our API usage. This makes me really curious to understand your use case.
- Why do you need send so often commands to your devices that are always device-specific?
- What is the underlying problem that you solve using it?
Cheers,
Marcin
Great to see you back on the forums!
If your aim is to propagate configuration information from Notehub to Notecard, then I think you would be better served to use environment variables instead of ordinary messages.
IIRC, they work outside of the rate limit constraints.
Let me confirm this before you rewrite your entire application. I should have an answer for you in about 24 hours.
Cheers,
Zak
After brainstorming your issue around the office, it seems like you may be better served by a “Batch Job”. They are designed to be asynchronous, self-throttling and can scale based on the provided parameters.
_______________
Also, here are some answers to specific questions you asked:
I saw in the docs that there is a 7 messages per minute limitation but would like to clarify if that includes access token requests as well?
no, it does apply to access token requests to the /oauth2/token endpoint
Also, is the 7 message limit windowed per minute or interval between messages?
it’s a windowed rate limit
Hopefully this gives you a path forward,
Zak
Thank you for your response and the information. In answer to your question, I have many fielded devices that operate in cooperation each with their own specific tasking. An end user creates a scenario that will start at time X, with devices specifically selected to perform their own part of the scenario. You could think of it as a script being passed out to all the actors(devices) with extra information for each actor on when and how to perform. It is currently sent as a .db note file. It would be a lot to stuff into environment variables but I will take a look at that path as well. Timing can be fairly critical hence my concern about the lag just to send the note files to notehub much less propagate through the cellular networks. My end users are used to some lag and know to make assignments well in advance but that doesn’t always happen or it generates concern when they send a command and nothing happens. Thanks again for your help.
I have been reading through the documentation and my current understanding is that batch files can only operate on environment variables and not stored notes? Is this accurate? With the access token request I can only configure up to 6 devices per minute? This seems extremely restrictive especially as I deploy more devices or am trying to run multiple operations at the same time. Thanks for your help.
Hi @szygmunt,
Just to clarify, API calls to the /oauth2/token endpoint do NOT count against your rate limit. Also, just so you know, you can now use Personal Access Tokens.
Thanks,
Rob
my current understanding is that batch files can only operate on environment variables and not stored notes? Is this accurate?
That’s right
With the access token request I can only configure up to 6 devices per minute?
you should only need to request an access token via /oauth2/token once every 30 minutes. In our next release this will be increased to 12 hours. Plus these requests don’t count against the API rate limit
It would be a lot to stuff into environment variables but I will take a look at that path as well
If I’m understanding correctly, you cannot set a fleet-level variable because the values need to differ slightly per device.
If this is the case, then it seems like your only option to get around the rate limit is to use batch jobs to set the environment variables on a per-device basis
However, we do not have public APIs for batch jobs yet. This should be fairly easy to add on our end though. There have been talks about getting these APIs added soon and it should be relatively straight forward.
Another option is for us to add support for .db files in batch jobs
Thanks for the response and information. I only request a new oauth token if the previous one has failed/timed out. Yes, fleet level variables will not work but per device might work. The configuration currently is a nested structure which gets converted back to a dictionary on receipt. Am I right that environment key value pairs are limited to 256 characters? Will keep looking into it to see if is an option that might work.
Support of batch changes for .db files would definitely be interesting.
Also, a request. Any chance a retry-after header can be added to the 429 error message? Currently can attempt to track the delay on my side or wait 60sec to be sure it’s cleared.