/delete-tweets

Project forked with some additional features for delete tweets automatically

Primary LanguagePythonISC LicenseISC

delete-tweets

PyPI version

This is a simple script that helps you delete tweets (or just replies or retweets) from your timeline. There are quite a few third-party services that allow you to delete tweets, but these very likely will not allow you to delete tweets beyond the infamous 3,200 tweet limit.

Prerequisites

Unfortunately, as of late 2018, you are required to have a Twitter Developer account in order to create a Twitter app.

Apply for a Twitter Developer account

  1. Create a Twitter Developer account:
    1. User profile: Use your current Twitter @username.
    2. Account details: Select I am requesting access for my own personal use, set your 'Account name' to your @username, and select your 'Primary country of operation.
    3. Use case details: select 'Other', and explain in at least 300 words that you want to create an app to semi-automatically clean up your own tweets.
    4. Terms of service: Read and accept the terms.
    5. Email verification: Confirm your email address.
  2. Now wait for your Twitter Developer account to be reviewed and approved.

Create a Twitter app

  1. Create a new Twitter app (not available as long as your Twitter Developer account is pending review).
  2. Set 'Access permissions' of your app to Read and write.

Configure your environment

  1. Open your Twitter Developer's apps.
  2. Click the 'Details' button next to your newly created app.
  3. Click the 'Keys and tokens' tab, and find your keys, secret keys and access tokens.
  4. Now you need to make these keys and tokens available to your shell environment. Assuming you are using Bash:

Steps to configure:

  1. Create a new .env file in the root of the project.
  2. Paste in the template below.
  3. Replace the key, secrets and token with the values from Twitter.
TWITTER_CONSUMER_KEY="your_consumer_key" # this is the API Token
TWITTER_CONSUMER_SECRET="your_consumer_secret" # this is the API Token Secret
TWITTER_ACCESS_TOKEN="your_access_token" # this is the Access Token
TWITTER_ACCESS_TOKEN_SECRET="your_access_token_secret" # this is the Access Token Secret

Get your tweet archive

  1. Open the Your Twitter data page
  2. Scroll to the 'Download your Twitter data' section at the bottom of the page
  3. Re-enter your password
  4. Click 'Request data', and wait for the email to arrive
  5. Follow the link in the email to download your Tweet data
  6. Unpack the archive
  7. Copy to here the file tweet.js, from data directory of Twitter archive

Getting started

Installation

Install the tool using pip.

python -m pip install delete-tweets
pip install -r requirements.txt

Usage

Delete any tweet from before January 1, 2018:

python deletetweets --until 2018-01-01 tweet.js

Or only delete all retweets:

python deletetweets --filter retweets tweet.js

Spare tweets

You can optionally spare tweets by passing their id_str, setting a minimum amount of likes or retweets:

python deletetweets --until 2018-01-01 tweet.js --spare-ids 21235434 23498723 23498723

Spare tweets that have at least 10 likes, or 5 retweets:

python deletetweets --until 2018-01-01 tweet.js --spare-min-likes 10 --spare-min-retweets 5

You can also delete tweets since a date (you cannot use a date range):

python deletetweets --since 2020-01-01 tweet.js