How to get tweet IDs (since_id, max_id) in tweepy (python)?

Dev Uberoi picture Dev Uberoi · May 29, 2012 · Viewed 12.3k times · Source

I want to know a way of getting tweet IDs to keep a check on what tweets have been displayed in the timeline of user in the python app I am making using tweepy.

There doesn't seem to be a way I get extract the tweet IDs or keep track of them. The parameter to keep check is since_id. Please if anyone could help.

Answer

Martijn Pieters picture Martijn Pieters · May 29, 2012

The tweepy library follows the twitter API closely. All attributes returned by that API are available on the result objects; so for status messages you need to look at the tweet object description to see they have an id parameter:

for status in api.user_timeline():
    print status.id

Store the most recent id to poll for updates.