Python – List object in Tweepy

Twitter is a popular social network where users share messages called tweets. Twitter allows us to mine the data of any user using Twitter API or Tweepy. The data will be tweets extracted from the user. The first thing to do is get the consumer key, consumer secret, access key and access secret from twitter developer available easily for each user. These keys will help the API for authentication.


The List object in Tweepy module contains the information about a list.

Here are the list of attributes in the List object :

  • id : The ID of the list.
  • id_str : The ID of the list as a string.
  • name : The name of the list.
  • uri : The URI of the list.
  • subscriber_count : The number of subscribers of the list.
  • member_count : The number of members of the list.
  • mode : The mode of the list.
  • slug : The slug of the list.
  • full_name : The full name of the list.
  • created_at : The time when the list was created at.
  • following : Indicates wehther the authenticated user is following the list or not.
  • user : The user object of the owner of the list.

Example : Use get_list() method to fetch the list.





# import the module
import tweepy
# assign the values accordingly
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
# authorization of consumer key and consumer secret
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
# set access to user's access key and access secret 
auth.set_access_token(access_token, access_token_secret)
# calling the api 
api = tweepy.API(auth)
# the ID of the list 
list_id = 4343
# fetching the list 
list = api.get_list(list_id = list_id)
# printing the information
print("The id is : " + str(
print("The id_str is : " + list.id_str)
print("The name is : " +
print("The uri is : " + list.uri)
print("The subscriber_count is : " + str(list.subscriber_count))
print("The member_count is : " + str(list.member_count))
print("The mode is : " + list.mode)
print("The slug is : " + list.slug)
print("The full_name is : " + list.full_name)
print("The list was created on : " + str(list.created_at))
print("Is the authenticated user following the list? : " + str(list.following))
print("The screen name of the owner of the list is : " + list.user.screen_name)


Output :

The id is : 4343
The id_str is : 4343
The name is : Thought Leaders
The uri is : /kitson/lists/thought-leaders
The subscriber_count is : 4066
The member_count is : 382
The mode is : public
The slug is : thought-leaders
The full_name is : @kitson/thought-leaders
The list was created on : 2009-10-15 23:03:44
Is the authenticated user following the list? : False
The screen name of the owner of the list is : kitson

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.