Skip to content

Pass along usage data with ratelimited requests and exceptions #325

Open
@cb109

Description

@cb109

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions