I am trying to get tweet replies of a chosen tweet using tweepy (academic access, API 2.0)
import tweepy
import time
bearer_token = "bearer_token"
twitter_client = tweepy.Client(bearer_token=bearer_token)
tweet = "numbers"
def check_replys(tweet_ID):
time.sleep(1) #where to put it?
query = f"conversation_id:{tweet_ID} is:reply"
replys= twitter_client.search_recent_tweets(query= query )
return replys
check_replys(tweet)
In response I get TooManyRequests: 429 Too Many Requests Too Many Requests
. I was googling around and I learned that tweepy might in some cases send too may requests than severs allows (because of academic access? Someone confirm that?) so I have added sleep.time(1)
, however it did not help at all. Can someone give me a hint how to fix it?
I am trying to get tweet replies of a chosen tweet using tweepy (academic access, API 2.0)
import tweepy
import time
bearer_token = "bearer_token"
twitter_client = tweepy.Client(bearer_token=bearer_token)
tweet = "numbers"
def check_replys(tweet_ID):
time.sleep(1) #where to put it?
query = f"conversation_id:{tweet_ID} is:reply"
replys= twitter_client.search_recent_tweets(query= query )
return replys
check_replys(tweet)
In response I get TooManyRequests: 429 Too Many Requests Too Many Requests
. I was googling around and I learned that tweepy might in some cases send too may requests than severs allows (because of academic access? Someone confirm that?) so I have added sleep.time(1)
, however it did not help at all. Can someone give me a hint how to fix it?
1 Answer
Reset to default 1You'll probably want to have more of a delay. The API rate-limits you, as you know. The list of rate-limits can be found here.
From what I could find, it appears that Tweepy gives you Basic Access. So, no more than 15 requests per 15 minutes. Unless I'm wrong about that, your sleep time should be at least 60 seconds (I would add in a few more seconds as a buffer though to avoid accidently hitting the limit)