In this article we will see how we can get number of statuses/tweets a user has tweeted/updated. The statuses_count attribute provides us with an integer which denotes the number of statuses the user has posted.
Identifying the date when a user was created in the GUI :
In the above mentioned profile, number of statuses the user has posted : 13.2K (13, 200+)
In order to get the number of statuses a user has posted, we have to do the following :
Identify the user ID or the screen name of the profile. Get the User object of the profile using the get_user() method with the user ID or the screen name. From this object, fetch the statuses_count attribute present in it. Example 1: Consider the following profile : We will use the user ID to fetch the user. The user ID of the above mentioned profile is 57741058.
import tweepy
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
id = 57741058
user = api.get_user(id)
statuses_count = user.statuses_count
print("The number of statuses the user has posted are : " + str(statuses_count))
Output :
The number of statuses the user has posted are : 13239
Example 2: Consider the following profile : We will use the screen name to fetch the user. The screen name of the above mentioned profile is PracticeGfG.
screen_name = "PracticeGfG"
user = api.get_user(screen_name)
statuses_count = user.statuses_count
print("The number of statuses the user has posted are : " + str(statuses_count))
Output :
The number of statuses the user has posted are : 2265
Last Updated :
18 Jun, 2020
Like Article
Save Article
Vote for difficulty
Easy
Normal
Medium
Hard
Expert