Delete All Tweets With Python



Using Tweepy to clear all tweets

If there's any need for deleting all your posts from Twitter here's a snippet to help you do such a thing.

import tweepy

consumer_key = 'XXXX'
consumer_secret = 'XXXX'
access_key = 'XXXX'
access_secret = 'XXXX'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)

api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

for status in tweepy.Cursor(api.user_timeline).items():
    id = status.id
    try:
        api.destroy_status(id)
        print(f'Deleted: {id}')
    except:
        print(f'Failed: {id}')

Thanks for reading. x

Resources