Skip to content
python script to backup/delete old tweets from your timeline
Find file
Pull request Compare This branch is 3 commits ahead, 7 commits behind olivierthereaux:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



OldTweets backs up (and deletes, if you so desire) all your tweets in separate files beyond the latest 50. Short URLs are expanded.


This script will work if, and only if, you:

  1. Install required libs (via pip install -r requirements.txt)
  2. go to, sign up with your account and create a new app (the details can be bogus, your app will be private)
  3. copy the consumer key and secret from your app in a credentials file
  4. go to "my access token" in the (righthand) menu of your app and copy the token and key in a credentials file (a credentials file is distributed with this script, as a sample. This file doesn't work)


Run it to see the output (change the path to save your tweets txt files)

cat credentials.txt | ./

Delete old tweets

cat credentials.txt | ./ --delete

Controlling how many tweets to ignore / keep in timeline

By default, the script will ignore the latests 50 tweets. If you want to choose another number (will be rounded down to the closest hundred):

cat credentials | ./ --keep=100


Based on a script by David Larlet (@davidbgk) Code, documentation and improvements contributed by Olivier Thereaux (@olivierthereaux), Karl Dubost (@karlpro), Florent Verschelde (@fvsch)

Something went wrong with that request. Please try again.