Do you have hundreds of embarrassing tweets on your Twitter profile, that you tweeted over a decade ago as an innocent high schooler, that is now causing you to cringe any time you think about them?
No?
Well, me either. (With the help of this script!)
python3
Follow the instructions here to generate the bearer and access tokens for the Twitter API. Verify that your access tokens allow read and write operations.
You should see something like this on your Twitter Developer Dashboard for your Project/App.
Make sure you copy and paste the Consumer API and Secret Keys
, Bearer Token
, and Access Token and Secret Keys
, and store them in a safe place!
In your terminal (or .bashrc
, .bash_profile
, .zshrc
, etc.) export the API keys keys as evironment variables. These will be used by the python script.
export 'BEARER_TOKEN'='<your_bearer_token>'
export 'CONSUMER_KEY'='<your_consumer_key>'
export 'CONSUMER_SECRET'='<your_consumer_secret>'
export 'ACCESS_TOKEN'='<your_access_token>'
export 'ACCESS_SECRET'='<your_access_secret>'
cd <your_local_path>/delete-tweets
pip install -r requirements.txt
The script will delete all your tweets that were authored before a given date. If you would like to delete tweets by another criteria, feel free to implement it, or create an issue / ask questions if you need help.
Open main.py
and update the DATE_CUTOFF
variable to any date you would like. Save the file.
python main.py
Voila! All embrassing tweets removed!
Due to the rate limits of the Twitter API, this script might take a while to complete depending on how many embarassing tweets you have. The DELETE
operation can only do 50 requests every 15 minutes. This script has automatic back-off, so just let it run in the background and do its thing.