Is there a common design pattern or library for external APIs with rate limits?

I wanted to play with GenStage and successfully built a small app that queues all requests and only consumes at the rate possible for the external API before being rate limited. I figured there might be a library that can help me do this and even help me cache the result as well. Does anyone know of anything?

1 Like

You mean a library on top of GenStage?

For caching there is nebulex, cachex, con_cache, etc

1 Like

do you mean something like hammer?

1 Like

There’s an example in the gen_stage docs: gen_stage/rate_limiter.exs at main · elixir-lang/gen_stage · GitHub
It’s fundamentally correct, but you may need to tweak it to your specific use-case or to make its inputs more accessible.

Yeah, on top of GenStage. Thanks for the caching resources.

This i what I tweaked and ended up using, but I was looking to see if someone created a library that is has more features and covers more use cases.

Not quite, but this will certainly come in handy for other things as well. Thank you!