Search code examples
twittertweepytweets

Is it possible to access the live tweets of a user using tweepy?


I am trying to access live tweets of a user whenever he tweets it. So, all I want is something that continuously monitors a user account and whenever he tweets something I have to capture it. All the tweets are random so I cannot use any filters.

For any security reasons, if I cannot access other's tweets can I do it on my own account?


Solution

  • With tweepy you can connect to the REST API or the Streaming API. Using the Streaming API you can use the filter endpoint to select the users you wish to follow with that streaming connection and you will receive updates as they get published.

    Twitter's documentation: https://dev.twitter.com/docs/api/1.1/post/statuses/filter, tweepy's code: https://github.com/tweepy/tweepy/blob/master/tweepy/streaming.py

    Tweepy's documentation doesn't give examples on the Streaming functions but you can find sample code searching at GitHub or StackOverflow for "tweepy filter follow".