So here's how I got rid of my Tweets: First step was to download my full Twitter archive, which gives you a list of all your Tweets in a condensed JavaScript file called tweets.js
. To make it readable from our python script, remove the first line of JavaScript to turn the whole file into a JSON array:
window.YTD.tweets.part0 = [
{
"tweet" : {
"edit_info" : {
…
turns into
[
{
"tweet" : {
"edit_info" : {
…
Now we can get down to business and iterate over the file to get all the Tweet ids. Use the tweepy library to talk to the old Twitter v1 API and delete your Tweets in Batch:
import tweepy
import json
# Generate those tokens at:
# https://developer.twitter.com/en/portal/projects-and-apps
consumer_key = "…"
consumer_secret = "…"
access_token = "…"
access_token_secret = "…"
auth = tweepy.OAuth1UserHandler(consumer_key, consumer_secret, access_token, access_token_secret)
api = tweepy.API(auth)
with open("<path-to-your-twitter-archive>/data/tweets.js", 'r') as file:
data = json.load(file)
for tweet in reversed(data):
if 'id' in tweet['tweet']:
print(tweet['tweet']['id'])
try:
api.destroy_status(tweet['tweet']['id'])
except tweepy.errors.NotFound:
print("Tweet no longer exists")
And that should be it. Fuck Twitter.