When consuming an API with state rate limits, how should one handle not exceeding them?

bugsmith
2023-06-16T16:40:44Z

My typical approach is one that I believe is pretty common: Reading the response header for current count and waiting if the limit is reached.

However, I am currently working with a couple of APIs which don't implement that and are currently set up with rate limits on an honesty system.

Is it a case of throwing sleep statements into you code, or using some kind of "bucket" and "lock" system?

I'd be interested to see any simple implementation people have used (the simpler the better).

Comments URL: https://tildes.net/~comp/16g0/when_consuming_an_api_with_state_rate_limits_how_should_one_handle_not_exceeding_them

Votes: 9

Comments: 6