Twitter Eraser
Time to cleanup my online data. Let’s start with Twitter. It should be easy for me to delete my old tweets, because I am control, right? Of course not 🤭
y u no close ur account
UPDATE 2024: account deleted. UPDATE 2025: looks like the best thing to do actually.
The joys of the incomplete API
So I am not closing the account at the moment. There must be an option in Twitter that allows me to delete old tweets to my liking, am I not?
🤣
Of course not. They do not want me or you to remove content from the platform. Some online applications allow you to do that. But I’m trying to regain control on my data. Giving access to it to a third party seems backward. There is a Twitter API I can use to do the job. Sure I can hack something in no time. Yes, there is an API. But it is disappointing.
First, you must request access to it, and give an explanation on what you intend to do with it. I suppose this leaves them the option to deny your request if you are building a competing service. It is legitimate, but in the end, your are dependant on their arbitrary approval for whatever legitimate usage you have. So here I go, explaining honestly what I intend to do. Request granted. Cool. Now I have the privilege to use their API.
(Un)surprisingly, there is no GET
operation on /tweets
to retrieve your own tweets. I can understand Twitter would not expose such endpoint to retrieve all the tweets in the universe. But to retrieve my own tweets? What would the issue be?
Using the quirky v. 1.1 API (you can tell they did not know what REST was when they designed it - some help here), you can delete a tweet. But you must know its identifier. And you can’t get a list your tweets and their IDs with the API. This is going to be tricky. 🤔
Instead, you can download an archive of all your data. It comes with a chilling effect: expect a 24-48h delay for them to build an archive with 3000+ tweets. As if they could not handle the load. But I am not giving up my plan so easily. I waited. It paid off.
The archive contains JSON files you can easily parse. Sample:
"tweet" : {
"retweeted" : false,
"source" : "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"entities" : {
"hashtags" : [ ],
"symbols" : [ ],
"user_mentions" : [ {
"name" : "ploum.net",
"screen_name" : "ploum",
"indices" : [ "3", "9" ],
"id_str" : "781660",
"id" : "781660"
} ],
"urls" : [ ]
},
"display_text_range" : [ "0", "140" ],
"favorite_count" : "0",
"id_str" : "257572918735810562",
"truncated" : false,
"retweet_count" : "0",
"id" : "257572918735810562",
"created_at" : "Sun Oct 14 20:05:43 +0000 2012",
"favorited" : false,
"full_text" : "RT @ploum: It's official: we missed 14 votes to have the first belgian pirate elected in Ottignies-Louvain-la-Neuve, a city of 30,000 in ...",
"lang" : "en"
}
Then, leveraging this neat little repository that relies on the archive you downloaded, you can proceed with mass deletion. Setup your credentials as explained, then for instance:
$ delete-tweets --until 2020-06-01 tweet.js
...
Number of deleted tweets: 3562
Off they go! Thousands of tweets deleted in a few minutes. ✨ Now I feel cleaner ✨
Who’s in control?
Make no mistake. This process, while within reach for the initiate, is not accessible to everyone. Even so, I had to assess several options, request access to the API, wait for the archive, read the doc, search for a library that would work. With Twitter, Facebook and the like, we are never really in control.