Skip to content

Instantly share code, notes, and snippets.

@davej
Last active March 27, 2024 03:12
Show Gist options
  • Star 97 You must be signed in to star a gist
  • Fork 43 You must be signed in to fork a gist
  • Save davej/113241 to your computer and use it in GitHub Desktop.
Save davej/113241 to your computer and use it in GitHub Desktop.
This script will delete all of the tweets in a specified account.
# -*- coding: utf-8 -*-
"""
This script will delete all of the tweets in the specified account.
You may need to hit the "more" button on the bottom of your twitter profile
page every now and then as the script runs, this is due to a bug in twitter.
You will need to get a consumer key and consumer secret token to use this
script, you can do so by registering a twitter application at https://dev.twitter.com/apps
@requirements: Python 2.5+, Tweepy (http://pypi.python.org/pypi/tweepy/1.7.1)
@author: Dave Jeffery
"""
import tweepy
CONSUMER_KEY = 'XXX'
CONSUMER_SECRET = 'XXX'
def oauth_login(consumer_key, consumer_secret):
"""Authenticate with twitter using OAuth"""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth_url = auth.get_authorization_url()
verify_code = raw_input("Authenticate at %s and then enter you verification code here > " % auth_url)
auth.get_access_token(verify_code)
return tweepy.API(auth)
def batch_delete(api):
print "You are about to Delete all tweets from the account @%s." % api.verify_credentials().screen_name
print "Does this sound ok? There is no undo! Type yes to carry out this action."
do_delete = raw_input("> ")
if do_delete.lower() == 'yes':
for status in tweepy.Cursor(api.user_timeline).items():
try:
api.destroy_status(status.id)
print "Deleted:", status.id
except:
print "Failed to delete:", status.id
if __name__ == "__main__":
api = oauth_login(CONSUMER_KEY, CONSUMER_SECRET)
print "Authenticated as: %s" % api.me().screen_name
batch_delete(api)
@nileshtrivedi
Copy link

Getting same problem which @argelouski reported. Account shows 8K tweets, none in the main timeline but all are there in "Replies" and "Media".

One approach would be to download your complete Twitter archive, extract tweet IDs from them and delete those.

@charlesstricklin-zz
Copy link

I've tried this, and the forked version of this, and neither deletes any of my tweets. At least this version tells me that it cannot for about 28 instances, each followed by an 18-digit number, each beginning with 80xxxxxxxxxxxxxxxx. Any idea what's wrong and what to do to correct it?

@mpahlevanzadeh
Copy link

I provided a secret key ,cunsomer key and verification code. But I don't how to run this script, Specialy I don't know where spread verification code.

@v0lsh3bnik
Copy link

Hey, if you are till looking for a script to delete all tweets you can check this one out : https://github.com/volshebnikRAJ/tweepy-api

@flesueur
Copy link

For those who want to delete older tweets, not available though the API, the following script uses tweet ids from a previously downloaded twitter archive : https://gist.github.com/flesueur/bcb2d9185b64c5191915d860ad19f23f

Copy link

ghost commented Jun 29, 2018

Here's a much more simple and easy way to delete tweets
https://gitlab.com/actualdragon/nuketweets

Download your tweet archive. Take the tweets.csv file and delete the tweets you want to keep or copy their ids and put them in the tweets_to_keep environment variable.

run script. nuke your tweets.

@jidanni
Copy link

jidanni commented Apr 24, 2019

@ghost that is a 404 link. But I found https://gitlab.com/chaimtime/nuketweets .

@murdoc02
Copy link

murdoc02 commented Feb 5, 2020

@polmaka
Copy link

polmaka commented Feb 20, 2020

hey murdoc02 can u help me how can i delete all my tweets? i have 40k tweets.

@polmaka
Copy link

polmaka commented Feb 20, 2020

i wrote this up:
https://github.com/murdoc02/twitterwipe

hey dude can u help me how can i delete all my tweets? i dont know how can i make a app from twitter.

@murdoc02
Copy link

murdoc02 commented Feb 20, 2020

i wrote this up:
https://github.com/murdoc02/twitterwipe

hey dude can u help me how can i delete all my tweets? i dont know how can i make a app from twitter.

set the number of days to 0 in my repo. after you got your auth set up just run it and you'll be good (not for likes though, but see my readme for that).

@arifsetyoaji
Copy link

i wrote this up:
https://github.com/murdoc02/twitterwipe

hey dude can u help me how can i delete all my tweets? i dont know how can i make a app from twitter.

set the number of days to 0 in my repo. after you got your auth set up just run it and you'll be good (not for likes though, but see my readme for that).

Hi!, I want to delete all my tweets. I do all instructions on your repo and get my auth to set up. But, after running it, my tweets it's still the same / not deleted.
Are there any specific settings when creating the API? Such as Permissions? cause, I only see permission to read and write, not to delete tweets.

@ihpannu
Copy link

ihpannu commented Nov 5, 2020

@smyja
Copy link

smyja commented Jan 5, 2021

Updated version to use with Python 3 https://gist.github.com/iharmanpannu/372788f40d9e7f12bd4baea195a14095

The link isn't working.

@amass01
Copy link

amass01 commented Feb 5, 2021

Updated version to use with Python 3 https://gist.github.com/iharmanpannu/372788f40d9e7f12bd4baea195a14095

The link isn't working.

just copy paste it

@jtheletter
Copy link

@wayne530
Copy link

A very simple NodeJS script to wipe all your tweets including step-by-step directions for obtaining all necessary tokens/keys:
https://github.com/wayne530/twitter-wipe

@nongiach
Copy link

@10ensura
Copy link

10ensura commented Jan 2, 2023

still working ? i need to do this on my tiwtter archive

@jtheletter
Copy link

Use this free plugin, it will automatically erase them.

Twitter or X: Delete all tweets free – Get this Extension for 🦊 Firefox (en-US)

That extension has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment