Search code examples
pythonmachine-learningtwittertweets

What is the way to extract all previous tweets about any topic from twitter?


The API search only provides previous 100 tweets. Is there a way to get all the tweets? I want to write a code in Python using AFINN library. Is there a place where I can get the code?


Solution

  • Look at https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html

    You can write a recursive search method. If there is a "search_metadata.next_results" in the json, then get the "max_id" and use it for the next search.

    So you can get a lot of tweets, but within the last 7 days with the public API.