openaq / openaq-api-v2

OpenAQ API
https://api.openaq.org
43 stars 9 forks source link

Rate limit headers #350

Open russbiggs opened 6 months ago

russbiggs commented 6 months ago

Currently we are using headers as drafted in this RFC: https://datatracker.ietf.org/doc/draft-ietf-httpapi-ratelimit-headers/

Given that this is not yet finalized we should maybe used custom X- prefixed headers in the meantime, then upgrade to the standard (if and when it finalizes) and decprecate the X- prefix.

Github's headers seem like a good one to follow

https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#checking-the-status-of-your-rate-limit

four43 commented 6 months ago

Check this one out: https://datatracker.ietf.org/doc/html/rfc6648

russbiggs commented 6 months ago

@four43 I've come across that "best practice" when investigating but it seems like hardly anyone is following it. Especially for the rate limiter headers given there is no finalized standard, it doesn't leave a lot of options. Even a quite new large scale API like OpenAI https://platform.openai.com/docs/guides/rate-limits/rate-limits-in-headers uses the X- prefix rate limiting headers.

four43 commented 6 months ago

I've landed on that as well in my projects. I just didn't want to bias you, just thought I'd throw out that resource. Cheers!