How to get twitter followers using Twython?

I'm the author of Twython. There's two different methods you can use for this; one that returns just follower IDs (get_followers_ids), and one that returns the statuses/etc of a follower set (get_followers_list).

Some example code for one would be like the following:

from twython import Twython

twitter = Twython()
followers = twitter.get_followers_ids(screen_name = "ryanmcgrath")

for follower_id in followers:
    print "User with ID %d is following ryanmcgrath" % follower_id

If you have IDs, you'd need to do further lookups yourself, so the latter method (get_followers_list) may be what you want. Keep in mind that Twython functions just mirror API key parameters from the official Twitter API docs, so the methods you can pass to an argument are the same as what you'll find on the docs.

Good luck!


from twython import Twython

twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

followers = twitter.get_followers_ids(id = 1234) # or just () - followers for your account

print(twitter.get_followers_ids()['ids']) # ids list of followers