Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass along usage data with ratelimited requests and exceptions #325

Open
cb109 opened this issue Dec 20, 2024 · 1 comment
Open

Pass along usage data with ratelimited requests and exceptions #325

cb109 opened this issue Dec 20, 2024 · 1 comment

Comments

@cb109
Copy link

cb109 commented Dec 20, 2024

I would like to be able to give feedback to users of our API once they run into the ratelimit, about how long they will have to wait until the limitation is lifted. That information is available already in the result of get_usage(...)["time_left"]", but using your @ratelimited decorator it is not passed along, all we get is either request.limited or we can handle the Ratelimited exception that doesn't carry the information either.

From what I understand I could write my own decorator or view logic from your building blocks to implement this, but I thought it might be worth thinking about this being a default behavior. I have used 3rd party APIs in the past that responded in such a way ("Your request was throttled, please try again in 0h 0m 59s") and found that very helpful as a user.

To illustrate: #324

It may be more complicated than it appears to me or you may have additional concerns about backwards compatibility that I am not aware of. In that case please feel free to dismiss this.

Anyways: Thank you for creating/maintaining and sharing this wonderful library!

@cb109
Copy link
Author

cb109 commented Dec 20, 2024

Reading a little more about it would make sense primarily to populate the value for this response header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant