What rate-limiting strategies work best with external APIs?

I’ve got a workflow that makes a lot of calls to an external API and I want to stay on the right side of its limits. What rate-limiting strategies work well in 3B? I’m curious how to pace requests, handle a limit when I hit one, and avoid getting throttled or blocked. Any patterns the community relies on would be really useful.

I would say this depends a lot on the API and how they implement rate limiting.

The simplest one is usually “if you get a 429, back of for a couple of seconds and retry”
(Tines 3B is very good at just taking instructions like that and make them part of the workflow)
And this works very well if the API endpoint is a minute by minute based rate limit (so the rate limit refreshes every minute)

some APIs also return a time to refresh or similar in the 429s, if that is the case a better option would be to tell 3B to wait till the refresh before retrying, (it may reduce the number of calls)

But if you are dealing with very low limit api with long cool down periods (like you are allowed 10 requests per day, or 1 request per hour or something like that)
You may actually consider doing something like a job queue, where 3B will keep a database of requests and wait for the API limit to reset before starting pulling the next job from the queue and calling out.

and be nice to your self and ask 3B to make you a nice interface where you can see the requests and re-arrange or reorder them (trust me, when you build a job queue like they there always comes a time where you want to either see or reorder the queue) :sweat_smile: