Detecting status update (new Tweet) from user


    down vote


I’m using R, specifically I’m using the filterStream package (Twitter streaming API library for R). I’d like to detect new tweets from a specified user.

The problem I’m having is that all replies to the user’s tweet are being detected as well. I just want the original tweet, when it happens.

Here’s the code for accessing the streaming api and getting tweets from a user (which includes replies to the user):

lastTweet <- filterStream("", follow=tuserID, timeout=3600, tweets=1, oauth=my_oauth)

I can program the script to detect if a tweet is a reply to the original tweet, by checking to see if there’s a user ID in the “reply to user” field, such as this:

tw <- parseTweets(lastTweet, verbose = FALSE)

tw$in_reply_to_user_id_str != tuserID #tweet is not a reply

…but that doesn’t help me “in real time,” as filterStream stores tweets until a maximum number or timeout has been reached, and I haven’t figured out how to evaluate the tweets as they’re being captured.

Any suggestions would be greatly appreciated. Thanks!


It doesn’t look like there’s a quick way to do this - but i’m not that great with R. Maybe there’s a way to modify filterStream to implement your own writefunction ?

It might be easier to do it Python - where a function is called for each individual tweet: (but i say “easier” only because i’m more familiar with Python than R)


Thanks for the suggestion. I’ve looked at the filterStream code, but I fear the limitation is within the Twitter API itself.

Does anyone know a way to do this with the Twitter API? I want to detect a user’s status update (new tweet), ignoring replies to that tweet. Currently, every time someone replies to my user’s tweet, it shows up in the stream. I want to filter out replies.



Yeah, unfortunately you can’t request to filter those out, by default the stream will send:

  1. Tweets created by the user.
  2. Tweets which are retweeted by the user.
  3. Replies to any Tweet created by the user.
  4. Retweets of any Tweet created by the user.
  5. Manual replies, created without pressing a reply button (e.g. “@twitterapi I agree”).

Given tuserID you’re interested in, If you check the user object in the tweet get the id, and ignore any that don’t match tuserID, you get just 1. and 2. to get rid of 2., check the tweet for retweeted_status field - if that doesn’t exist, you’re left with 1. Just tweets created by the user. All this checking has to be done in your code somewhere.

Hope that helps!