Search code examples
twitter-oauthhashtag

How get all tweets count of a hashtag


I am using TwitterOAuth to get the tweet count of a hashtag but there is one issue; It only returns maximum of 100 results.

I want to get all tweets of a hashtag. Is this possible? Is so, how?


Solution

  • I assume you are using get parameter on this url as you haven't shared code.

    https://api.twitter.com/1.1/search/tweets.json?q=??&count=??
    

    So you need to specify count here which is described in following twitter api docs.

    https://dev.twitter.com/docs/api/1.1/get/search/tweets

    Yes there is 100 count limitation. So in that case page parameter can be added but twitter has written why timeline option is better.

    https://dev.twitter.com/docs/working-with-timelines

    So answering your question you will using query something like this. This will give 2nd page with 100 results. Read the link above to use options like max_id and since_id.

    https://api.twitter.com/1.1/search/tweets.json?q=google&count=100&since_id=100
    

    This way extend your 100 results limit and you can always test your query on

    https://dev.twitter.com/console