Twitter's user_timeline only returns a couple of the tweets (2 of them), not all of them


#1

So, a friend of mine ( http://twitter.com/mr_jese ) is using a plugin that needs to select user tweets via the Twitter API. But the weirdest thing is happening: the Twitter user_timeline request is only sending back 2 tweets–even when the count is set much higher!

To reproduce:

  1. Go to https://dev.twitter.com/rest/tools/console
  2. Sign in (top right)
  3. On the Authentication dropdown, choose OAuth 1 and allow
  4. On side panel, choose GET /statuses/user_timeline.json
  5. Choose the following query parameters:
  • count: 10 (or anything higher than 3)
  • exlude_replies: true
  • include_rts: false
  • screen_name: mr_jese
  1. Click the big orange “Send” at the top.

Viola! It only returns 2 tweets…even though my friend has many more than 2 tweets.

Why? Any ideas?


#2

Yes, this is not an issue with the Twitter API.
Please read the Docs carefully:

The value of count is best thought of as a limit to the number of tweets to return because suspended or deleted content is removed after the count has been applied. We include retweets in the count, even if include_rts is not supplied. It is recommended you always send include_rts=1 when using this API method.

(I am pretty sure that exclude_replies is applied after the count, too.)

So this means, that even if you have a count of 10, it will filter out the RT’s and replies, so you end up with only 3 Tweets. If you choose a higher count, you will get more replies.


#3

Very interesting! I didn’t realize that.

Is there any way to actually select the amount of tweets (excluding RTs and replies) returned? Or would you just have to check what was returned and keep sending more requests the desired number was accumulated (that seems like a pretty expensive approach).


#4

You could just choose a bigger count, and then omit some of the Tweets.


#5

That’s true, that’s not totally reliable though–considering some people could have an excessively large number of replies/RTs.

I guess a combination could work. Larger count + re-request if the request returned too few.


#6

I find it somewhat funny that all the filtering of set option values are applied after the search making the count invalid. Wouldn’t it be easier to apply these options to the queries so the count actually matters?

I recently observed this behaviour when setting count to 3 and setting retweets and replies to false, the API only returns 1 tweet for me, so the only option was to increase the count to 20 and slice the returned response array for the count I want.