Josh Josh - 7 months ago 36
Python Question

Retrieving tweets in chronological order using tweepy for python

I have written a Python script that uploads 6 URL's in each tweet to Twitter. I use the

API call to pull down all the posts that are made, effectively shortening the URL's that I posted to twitters URL's.

My problem is that the
call does not order the tweets chronologically.

In a Twitter timeline the most recent tweet is posted at the top. I would prefer it, if I could read back the timeline from the bottom, which is where my first tweet would start.

This is the code I'm using to retrieve the tweets on my timeline from twitter:

user_tweets = api.user_timeline()
for tweet in user_tweets:
print tweet.text

Does anyone have an idea of how I can use tweepy or just the twitter REST API to reverse the order of how it retrieves the tweet?


You can reverse the list and print it out that way

for tweet in reversed(user_tweets):
    print tweet.text