question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rate limits remaining of Twitter API v2

See original GitHub issue

Hi, using Twitter API v2, I found that we couldn’t confirm remaining of rate limits by each response with tweepy/client.py.

Rate limits doc: https://developer.twitter.com/en/docs/twitter-api/rate-limits

So, I’d like to propose to extend tweepy/client.py a little below.

# before
Response = namedtuple("Response", ("data", "includes", "errors", "meta"))

# after
Response = namedtuple("Response", ("data", "includes", "headers", "errors", "meta"))

And just add the headers of requests.response into Response in Client._make_request method.

Then, we can check the remaining of rate limits for each endpoint’s return value, such as response.headers['x-rate-limit-remaining']. I’d be grateful if you could look into that 😄

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rnakashirocommented, May 8, 2021

Thank you for reply.

The use cases are, to show rate-limits for users, to prevent 429 response before API call when remaining are 0, and so on.

Official Twitter API provides a way to check rate-limits for every response, but that’s omitted now, so this lib is ideal to inherit the Twitter’s feature 😄

0reactions
rnakashirocommented, May 9, 2021

Oh, sorry. I’m using with commit-hash git+https://github.com/tweepy/tweepy.git@9a28e0eaa7329918bfbf19e08afccb473210a2d1 in requirements.txt, and reviewed this lib’s code on Github.

I’m interested in Twitter API v2’s arrival and this lib’s support. So, I proposed a little change. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rate limits | Docs | Twitter Developer Platform
Twitter API v2 rate limits ; Manage follows. Follow a user, 400 successful requests per 24-hour window per user 1000 successful requests per...
Read more >
What is the true rate limit for v2? - Twitter API
What is the true rate limit for v2? · 120 request per second (or is 60 the max?) · 7200 requests per hour...
Read more >
node-twitter-api-v2/rate-limiting.md at master - GitHub
Plugin @twitter-api-v2/plugin-rate-limit can help you to store/get rate limit information. It stores automatically rate limits sent by Twitter at each ...
Read more >
Twitter API V2 - Increase Rate Limit and Get Rate Limit Status
Direct Messages (daily): The limit is 1,000 messages sent per day. · Tweets: 2,400 per day. The daily update limit is further broken...
Read more >
twitter-api-v2/plugin-rate-limit - NPM Package Overview
Rate limit plugin for twitter-api-v2. Version: 1.1.0 was published by alkihis. Start using Socket to analyze ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found