How to get specified number of tweets using Streaming API?

streaming
python
api

#1

Hi All,

I am working on self-made and self-learning project which will predict the possible US president for 2016 using social media data.
so I started with twitter using search API and Streaming API. These are very great APIs and I love them.

Now what I need is getting specified number of tweets or getting tweets for a specified amount of time. I have looked into the streaming API request parameters and I have not found anything related to my needs.

I am looking for something like

https://stream.twitter.com/1.1/statuses/filter.json?track=%23Trump2016&number=500” which will get me 500 fresh tweets. or
"https://stream.twitter.com/1.1/statuses/filter.json?track=%23Trump2016&time=60" which will get me tweets for 1 hour.

I know search API can do this by giving rpp parameter but I need that for streaming API.

Is there anyway to do that?
I appreciate some help :smile:

Thanks in advance.


#2

Simply close the stream after you have consumed enough tweets.