Take the 2-minute tour ×

I am storing in a database, every 30 minutes, Twitter's trending topics of a country Y. No problem with that. Now, I want to get as much tweets as possible matching those trending topics for research purposes.

Since I would like to study the patterns of the trends, I would like continuous tweet data of at least 3 days centered in the day the trend peak was detected, for every trending topic. In order to achieve that, I thought of doing the following:

Suppose I am in day X. I could retrieve the unique trends of day X-2, and for every trend, look for tweets matching the trend in the interval [X-3, X-1], that is 3 days. However, the problem here is Twitter rate limitations. If I have 100 trending topics in day X-2, and I make 20 GET search requests/trend, I would end up doing a total of 2,000 requests, which overpasses Twitter's 350 hourly rate limit. If make 300 req/hour, it would take more than 6 hours to get the data for only one day...

Does anybody know any other (better) way for getting tweets associated with trends?

Thanks in advance

share|improve this question
add comment

1 Answer

Twitter Streaming API?

Twitter Streaming API doesn't deliver any past tweets. You only receive tweets starting from the time the server connection is established. The search API will return tweets matching the current query up to 7 days old in theory, but that is entirely up to Twitter’s current load. (Note*-At times this interval has been as short as 24 hours. In addition, you are limited by the ability to only receive up to 1,500 tweets regardless of how old they are.)

Is there any way to get more tweets from the streaming?

None that I know. But, do refer the below mentioned information if you are considering to switch among search or streaming API.

Please choose your case:

  • If you need real time data and your number of requests are high:

Go for Streaming API

The streaming API requires that you keep the connection active. This requires a server process with an infinite loop, to get the latest tweets.


1)Lag in retrieving results: Tweets delivered with this method are basically real-time, with a lag of a second or two at most between the time the tweet is posted and it is received from the API

2)Not rate limited.

  • If you need aggregate data regardless of its time range and your number of requests are not high:

Go for Search API

The search API is the easier of the two methods to implement but it is rate limited .Each request will return up to 100 tweets, and you can use a page parameter to request up to 15 pages, giving you a theoretical maximum of 1,500 tweets for a single query.


1)Finding tweets in the past:The search API wins by default in this area, because the streaming API doesn’t deliver any past tweets

2)Easier to implement

share|improve this answer
Please don't post duplicate answers. If two (or more) questions truly can be answered by the exact same answer (at least of this size), then they are duplicates, otherwise the answers (at least some of them) are inappropriate. Instead, tailor each answer to the specific question at hand. –  Lasse V. Karlsen Mar 28 '12 at 11:48
Thanks for the reply. Since I need to get past data which would correspond to past trends, I am not using Streaming API, of course. So the problem would be how to use the Search API to maximize the number of tweets retrieved in view of the rate limit... What I am doing now is getting tweets, sleep, keep getting tweets, sleep, etc. It works but there must be a better option... –  D T Mar 28 '12 at 11:58
@LasseV.Karlsen I thought the answer would help both, so pasted. Thanks for the information.Next time will share the link instead. –  samridhi Mar 28 '12 at 15:00
add comment

Your Answer


