You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Twitter puts some information about your account’s rate limits in the response headers of every request. Most important is the time at which your rate limit is reset after a 429 response. See the documentation at https://developer.twitter.com/en/docs/twitter-api/rate-limits for all of the details.
I would like there to be some way to access this information, so that I can act on it. As a quick test, I tried sticking it on to the ApiError struct:
ApiError { title: "Too Many Requests", kind: "about:blank", status: 429, detail: "Too Many Requests", errors: [], reset: Some(1660051376) }
I added the simplest possible thing to api_error_for_status in api_result.rs:
let reset = self.headers().get("x-rate-limit-reset").map(|v| v.to_str().unwrap().parse().unwrap());
and then added the resulting value to the ApiError that it creates.
This works, but it is not very elegant. It leaves two of the headers unavailable, and it would be rather nicer if it created a std::time::Duration for me, though that might be going a bit far. It also doesn’t do anything to make this information available on successful requests.
Do you prefer any particular way of implementing this?
The text was updated successfully, but these errors were encountered:
Twitter puts some information about your account’s rate limits in the response headers of every request. Most important is the time at which your rate limit is reset after a 429 response. See the documentation at https://developer.twitter.com/en/docs/twitter-api/rate-limits for all of the details.
I would like there to be some way to access this information, so that I can act on it. As a quick test, I tried sticking it on to the
ApiError
struct:I added the simplest possible thing to
api_error_for_status
inapi_result.rs
:and then added the resulting value to the
ApiError
that it creates.This works, but it is not very elegant. It leaves two of the headers unavailable, and it would be rather nicer if it created a
std::time::Duration
for me, though that might be going a bit far. It also doesn’t do anything to make this information available on successful requests.Do you prefer any particular way of implementing this?
The text was updated successfully, but these errors were encountered: