How to receive all tweets mentioning a specific user through Streaming API


#1

I am in the process of building an application that will automatically respond to @ mention tweets. It will be similar to @klmfares for example. @klmfares is specifically listed as a good example in the “Automation Best Practices” site, so I assume this is an ok kind of application.

However I am not receiving the majority of the test tweets mentioning my user when I’m connected to the streaming API. Like @klmfares, the application won’t make much sense if only a small sample of tweets are received and replied to. Here’s the url I’m using: https://stream.twitter.com/1.1/statuses/filter.json The POST has “track: userid” as its content.

Do I need Firehose access for this? It seems like there should be an easier and cheaper way to do this.


#2

The Firehose wouldn’t be of much use in your case.

When you say track=userid, what do you mean by “userid”? The numerical id or the screen name? Saying that the user is @klmfares would that be “track=klmfares”? That should get you almost all mentions.

You can also try with user streams (https://dev.twitter.com/docs/streaming-apis/streams/user), or calling regularly https://dev.twitter.com/docs/api/1.1/get/statuses/mentions_timeline.


#3

Hi Vincent, thanks for your reply. On your suggestion I tried a User Stream for my application. Unfortunately, this did not capture the majority of the test tweets that I sent. I do think this is the most correct option, though.

So, two questions:

  1. Should I expect all tweets mentioning my user (@divvidend) to arrive in my connection to the user stream?
  2. What is the best way to test this? I don’t want to get blocked by spam detection due to repeated test tweets to the @divvidend user.

#4
  1. You should definitely get most tweets mentioning the user. Only the tweets of very few users (considered as very low quality) should not get through. The only way to get all tweets would be to statuses/mentions_timeline, but you would like the real-time of the streaming API.
  2. Don’t hesitate to create 2 or 3 accounts to test. Just testing by hand shouldn’t make you blocked by spam detection. Though when creating a test account you should make sure to verify the email address (meaning clicking on the verification link in the email you get when creating an account).

#5

Ok thanks for the advice. I think my account might be one of those “very low quality” accounts due to lack of real tweets or followers.

Is there any way to check this? I’d guess not.


#6

The only way to check it is to tweet some text without any link, and then search for from:accountname (replacing of course accountname with the account’s name), and click on “All” on top to see all the recent results. If the tweet doesn’t show up, that account’s tweets will very likely not show up in statuses/filter.