Queries not returning 200 (max) tweets

Mar 17, 2013 at 4:42 AM
I'm having trouble getting the max 200 tweets back from Status.Count. For my main test user (has 247 tweets) I only get 178 back. I've tried with users that have 5,000 plus tweets and it varies, but never reaches 200.

I'm currently cycling through, grabbing as many tweets as possible per query. It works, but it would be nice to work with a consistent number for some future updates I'm planning.

As of now, I haven't found a distinct pattern to predict the number I get. It varies per user, but stays the same for each specific user.

        public List<Status> GetTweets(WebAuthorizer auth, TwitterContext twitterCtx, int sCount)
        {
            var userStatusResponse =
                (from tweet in twitterCtx.Status
                 where tweet.Type == StatusType.User &&
                       tweet.ScreenName == txtScreenName.Text &&
                       tweet.Count == sCount
                 select tweet).ToList();

            
            return userStatusResponse;
        }
        public List<Status> GetMoreTweets(WebAuthorizer auth, TwitterContext twitterCtx, int sCount, ulong lastID)
        {
            var userStatusResponse =
                (from tweet in twitterCtx.Status
                 where tweet.Type == StatusType.User &&
                       tweet.ScreenName == txtScreenName.Text &&
                       tweet.Count == sCount &&
                       tweet.MaxID == lastID
                 select tweet).ToList();


            return userStatusResponse;
        }
'sCount' = User.StatusesCount

Am I missing something in my query for getting all 200?
Coordinator
Mar 17, 2013 at 4:53 AM
Make sure you set your count to 200, which is the max you can request on a single query. Then page through results until you don't receive any more. The max is 3200. I wrote a blog post for Working with Timelines with LINQ to Twitter - it isn't obvious why you have to do this until you read through my explanation and read Twitter's explanation too.

I'm not sure of all the reasons why you wouldn't receive all the tweets, but I know it happens, but whatever data Twitter returns is available through LINQ to Twitter too. Some times it's helpful to search through the Twitter Developer Discussion List to see if other people have asked the same question.

@JoeMayo
Mar 17, 2013 at 5:19 AM
Thank you. Even with an explicit count of 200 declared, I get just under that. It is closer to 200 as a users total tweet # increases.

I also noticed that the TOTAL number of tweets you can recall is affected by this. It's like the Twitter service thinks you are getting all 200 each time. For example:

I ask for 200 tweets
I get 183 tweets
Maximum possible tweets = 3,111

Assuming you are requesting 200 tweets per request
maxReturnedTweets = tweetsPerRequest * Math.Floor(3200/tweetsPerRequest)