How I deleted all my old tweets using Python

I don’t like the idea of leaving around too many “historical” tweets with all the dumb things I tweet about.

So I decided to delete them all.

To do so I requested an archive of all my tweets on Twitter, from the Twitter set…


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com

I don’t like the idea of leaving around too many “historical” tweets with all the dumb things I tweet about.

So I decided to delete them all.

To do so I requested an archive of all my tweets on Twitter, from the Twitter settings.

The archive can take days to generate. My archive dated back to 2015, although I use Twitter since 2007. Maybe I already removed my past tweets in 2015, I don’t remember.

I got the archive, I downloaded it, then I unpacked the folder and I ran

python -m venv .venv
source .venv/bin/activate.fish
python -m pip install delete-tweets

Then I created the environment variables to set the keys of a Twitter app, required to run the whole process, as described on https://github.com/koenrh/delete-tweets:

export TWITTER_CONSUMER_KEY="your_consumer_key"
export TWITTER_CONSUMER_SECRET="your_consumer_secret"
export TWITTER_ACCESS_TOKEN="your_access_token"
export TWITTER_ACCESS_TOKEN_SECRET="your_access_token_secret"

I used the consumer and access keys of a Twitter app I already had (Twitter now has a process to create new apps, so you must be reviewed and approved to do the same if you don’t have an app already there).

Tip: when you define environment variables in this way, they are recorded by default in the shell history. To avoid that with the Fish shell, run a new shell with fish --private to start the shell in private mode.

Then I ran:

delete-tweets --until 2021-01-01 tweet.js

to delete all the tweets I tweeted before 2021. It took a little while, but it worked.

It took way more to get the archive from Twitter than to delete the tweets, but in the end I got a clean slate.


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com


Print Share Comment Cite Upload Translate Updates
APA

flaviocopes.com | Sciencx (2021-01-12T05:00:00+00:00) How I deleted all my old tweets using Python. Retrieved from https://www.scien.cx/2021/01/12/how-i-deleted-all-my-old-tweets-using-python/

MLA
" » How I deleted all my old tweets using Python." flaviocopes.com | Sciencx - Tuesday January 12, 2021, https://www.scien.cx/2021/01/12/how-i-deleted-all-my-old-tweets-using-python/
HARVARD
flaviocopes.com | Sciencx Tuesday January 12, 2021 » How I deleted all my old tweets using Python., viewed ,<https://www.scien.cx/2021/01/12/how-i-deleted-all-my-old-tweets-using-python/>
VANCOUVER
flaviocopes.com | Sciencx - » How I deleted all my old tweets using Python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/01/12/how-i-deleted-all-my-old-tweets-using-python/
CHICAGO
" » How I deleted all my old tweets using Python." flaviocopes.com | Sciencx - Accessed . https://www.scien.cx/2021/01/12/how-i-deleted-all-my-old-tweets-using-python/
IEEE
" » How I deleted all my old tweets using Python." flaviocopes.com | Sciencx [Online]. Available: https://www.scien.cx/2021/01/12/how-i-deleted-all-my-old-tweets-using-python/. [Accessed: ]
rf:citation
» How I deleted all my old tweets using Python | flaviocopes.com | Sciencx | https://www.scien.cx/2021/01/12/how-i-deleted-all-my-old-tweets-using-python/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.