A simple utility script that deletes your old tweets based on a given cut off date.
Motivation for creating this utility is on my blog post.
If you found this to be useful, please give it a star.
Due to twitter's API rate limit, by default, a limit of 100 deletions has been set when you execute the script. There is also a hard limit of 2400 updates to tweets per day. Please be aware of the rate limits, otherwise your account may be suspended.
- Tested on NodeJs v18.x
npm install
-
Request your twitter data from Twitter (link). You will receive an email in your email with a download link to your data, this may take a some time especially if you have a lot of twitter data.
-
You need a valid Twitter developer credentials in the form of a set of consumer and access tokens/keys (link). You will also need to grant write permission to your application.
-
Extract your twitter data and copy
data/tweets.js
into the scripts working directory -
Copy the sample
.env
filecp .env.sample .env
-
Edit the
.env
file and replace the placeholders with your twitter app tokens/keys obtained earlierTWITTER_CONSUMER_KEY=**your key** TWITTER_CONSUMER_SECRET=**your secret** TWITTER_ACCESS_TOKEN_KEY=**your token key** TWITTER_ACCESS_TOKEN_SECRET=**your token secret**
-
Execute the script (below will delete 100 tweets before 2011-01-01)
node index.js -d 2011-01-01
-d
- cutoff date in yyyy-mm-dd format-n
- number of tweets to delete (optional, default to 100)
-
IDs of deleted tweets will be written to
deleted.js
-
Rerun the script to continue the next batch of tweets
To see all of the scripts options, please run node index.js -h
Originally authored by @hbish
Special thanks to Twitter for Node.js for the awesome twitter client.