Skip to content

Instantly share code, notes, and snippets.

@harryawk
Last active May 31, 2023 03:52
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harryawk/706d44ed80ca24d22d8a52987ab54ab5 to your computer and use it in GitHub Desktop.
Save harryawk/706d44ed80ca24d22d8a52987ab54ab5 to your computer and use it in GitHub Desktop.
Script to delete all your tweets and replies
"""
This script is using python-twitter SDK (https://github.com/bear/python-twitter)
All key and secret strings can be generated by creating an app in https://apps.twitter.com/
"""
import twitter
consumer_key = ''
consumer_secret = ''
access_token_key = ''
access_token_secret = ''
api = twitter.Api(
consumer_key=consumer_key,
consumer_secret=consumer_secret,
access_token_key=access_token_key,
access_token_secret=access_token_secret
)
# Delete own tweets
owned_status = api.GetUserTimeline(count=200)
num_owned_status = 0
while(len(owned_status) > 0):
for s in owned_status:
api.DestroyStatus(s.id)
print('One tweet deleted')
num_owned_status += 1
owned_status = api.GetUserTimeline(count=200)
print('Your ' + str(num_owned_status) + ' tweets has been deleted.')
# Delete replies
owned_replies = api.GetReplies(count=200)
num_owned_replies = 0
while(len(owned_replies) > 0):
for s in owned_replies:
api.DestroyStatus(s.id)
print('One reply deleted')
num_owned_replies += 1
owned_replies = api.GetReplies(count=200)
print('Your ' + str(num_owned_replies) + ' replies has been deleted.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment