Today I was experimenting with the API and received quite a few messages indicating I overstepped some kind of rate limit. But what are those limits exactly?
On https://developer.supernotes.app/api-reference/resource-limits it says “Additionally, Unlimited Plan users are granted “trusted” status, which significantly reduces the likelihood of encountering rate limits.” which would imply my usage, but still, after about a few hundred calls I run into rate limits. For now I have resolved this by adding some pauses into my script, but it would be nice to know the exact limits, so I can anticipate them.
Rate limits are somewhat dynamic based on the usage from your account. Generally you shouldn’t need to worry too much about hitting them, can I ask what type of calls you were making? Certain calls are also rated as more “expensive” than others and will cause hitting rate limits sooner.
Unfortunately we’ve had to deal with multiple DDoS attacks over the years, so API access is a bit more strict than we’d like it to be, but if you let us know how you’re using it we could maybe point you in a better direction (and if a large volume of requests is routinely required for your use-case we can probably reduce restrictions on particular accounts).
Today I ran a script changing the titles of my daily notes (around 400 of them). That entails two calls: one to check if the note exists with a certain title, and if it does, another one to patch it to a new title. I built in pauses of half a second between calls. After about 400 calls (half of my notes), I hit the rate limit. So just 2 calls per second or 400 calls in 200 seconds. Is that too much?
Gotcha. Yep, that is generally not how you should be doing a bulk update with the Supernotes API. Instead of 2 calls per card, there should be two calls total: one to fetch the cards you need (if even necessary) and one to update them.
Not sure how you are determining which cards need to be updated (and how you are getting them), but generally it should be possible to get all the cards you need using a single POST:/v1/cards/get/select request. Once you have them, you can determine whether or not they need to be updated locally, then send all of the card updates at once with a PATCH:/v1/cards request. The payload for that request might look like this for your use-case: