Disabling All Retweets

First post of 2020!

One thing I do to keep my Twitter feed under control is disabling all retweets. This makes a big difference because then you get more original or personal content instead of just retweets of the Horrible News Of The Day. Of which there seems to be a lot these days.

Turning off retweets is pretty simple - just go to a friend’s profile and hit the kebab menu. The first option should be “Disable Retweets”.

This is a good candidate for a little bit of automation, so here is a small Python script that disables retweets for all people you follow.

#!/usr/bin/env python3

import os, time
import twython

CONSUMER_KEY = os.getenv("CONSUMER_KEY")
CONSUMER_SECRET = os.getenv("CONSUMER_SECRET")

ACCESS_TOKEN = os.getenv("ACCESS_TOKEN")
ACCESS_TOKEN_SECRET = os.getenv("ACCESS_TOKEN_SECRET")

if __name__ == "__main__":
    twitter = twython.Twython(CONSUMER_KEY, CONSUMER_SECRET,
                              ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
    for friend_id in twitter.get_friends_ids()['ids']:
        print(f"Disabling retweets for {friend_id}")
        twitter.update_friendship(user_id=friend_id, retweets=False)
        time.sleep(5)

The time.sleep(5) is in there to not hit Twitter’s ridiculous low API rate limits. Obtaining the OAuth tokens may be a bit tricky, but if you know how to do that, you should have no trouble running this script.

(I registered an application on developer.twitter.com that I use for some personal scripts that interact with Twitter.

Full code at github.com/st3fan/disable-all-retweets.

Most of my professional and personal work is Open Source. You can find many projects at github.com/st3fan - feel free to leave a bug report or open a feature request.