-3

I need an advice.

I'm trying to understand the Twitter API rate limit.

I have a csv file with approx 10000 Twitter handles.

I need to download tweets and retweets of these users.

If I loop over the handles and download the data - how will this affect the rate limit of Twitter? How many calls can my script make pr hour without being blacklisted?

Would this be possible with Stream API instead?

I'm going to use Python and Tweepy for this.

Thanks in advance.

karramsos
  • 1
  • 3

1 Answers1

2

It is possible, but you'll need to stagger it to respect the rate limit. I use something like this (from previous answers: 1, 2):

alltweets = []
new_tweets = api.user_timeline(screen_name = screen_name,count=200) 

# save most recent tweets
alltweets.extend(new_tweets)

# save the id of the oldest tweet less one
oldest = alltweets[-1].id - 1

#keep grabbing tweets until there are no tweets left to grab
while new_tweets:       
    try:
        new_tweets = api.user_timeline(screen_name = screen_name,count=200,max_id=oldest)
    except tweepy.TweepError:
        time.sleep(60 * 15)
        continue

```

finbarr
  • 749
  • 4
  • 11