Using tweepy: how to retrieve all tweets within past 5 minutes

3.3k Views Asked by At

Im using tweepy to search for a keyword in all tweets in the last 5 minutes. But I couldn't find a way to do this. I saw the since_id and max_id arguments, but they only work if I know the tweet_id before 5 minutes.

1

There are 1 best solutions below

5
On

There is no specific GETfeature that would allow that.

What you'll need to do is create a search for that keyword and Get search/tweets and use the since_id and max_id like you have and look at time_created_at from the JSON and filter yet again using that.

The problem with the previous step is that you're limited to 180 tweets /15 minutes. Another solution is to use the streaming API since it'll give you recent information most are within 5 minutes and you'll be able to filter by keywords as well.