User timeline `max_id`, and `since_id` not working as expected


The Twitter API says I can only gain a maximum of 200 per query, up to a maximum of 3,200 Tweets in total, however, I am unable to use max_id to get the Tweets past the first 200, or if I test it manually, when I set count, and max_id to the ID of the Tweet I got, I never get the next Tweet. Is there something I am missing in the API docs? Or… is there a way to iterate backwards over the users timeline to get all the Tweets upfront?


Per the working with timelines documentation, on the first call, you’ll want to just provide the count of 200; after that, provide the max_id -1 of the last Tweet on the from the previous call. This should enable you to page back through 3200 Tweets.

For the account whose timeline you’re trying to access, is the last Tweet particularly “old” - i.e. how many days back does the first call reach?


@andypiper t went back 3 days. It turns out the problem is with the way the API handles the max_id call on the next iteration (in the case of the manual testing.) On the other side my code had a minor bug in it. That led to confusion, because when I went to manually test the API with a count=1 it could never work because Twitter always returns the value of max_id as the first result, so you can never do max_id and count=1. After I discovered that I did count=2 a couple of times, and then went to track down where the recursion bug was in my code, turned out I reflected wrong on an object.


Sounds like you’re all set - glad you got it figured out!