Skip to content

Instantly share code, notes, and snippets.

@smortime
Last active April 24, 2020 10:57
Show Gist options
  • Save smortime/22d896b5d798b6f094e3a38ddfd64227 to your computer and use it in GitHub Desktop.
Save smortime/22d896b5d798b6f094e3a38ddfd64227 to your computer and use it in GitHub Desktop.
Script to delete all of your tweets. Requires Python 3.x, Twython, and API keys.
#Schuyler Mortimer
from twython import Twython
import sys
#get from twitter developer site
APP_KEY = ''
APP_SECRET = ''
TOKEN = ''
TOKEN_SECRET = ''
def batch_delete(twitter):
#ran into a 200 tweet limit, loop gets around this
while True:
#get the timeline
try:
timeline = twitter.get_user_timeline(count=200)
except:
print("You made a mistake.")
sys.exit()
if len(timeline) == 0:
print("No tweets left to delete")
break
#delete the timeline
for tweet in timeline:
status = int(tweet['id_str'])
twitter.destroy_status(id=status)
print('Tweet deleted: ' + str(status))
print(len(timeline))
def main():
twitter = Twython(APP_KEY, APP_SECRET, TOKEN, TOKEN_SECRET)
batch_delete(twitter)
if __name__ == '__main__':
main()
Copy link

ghost commented Feb 2, 2017

I found this useful!

@bhavul
Copy link

bhavul commented Mar 28, 2020

Thanks. Was useful to me as well.

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