Python Tweepy – Getting the ID of a user Improve Improve Improve Like Article Like Save Article Save Share Report issue Report In this article we will see how we can get the ID of a user. ID is the unique identification marker of the twitter account. ID is given to the user by Twitter, the user can not select or change their own ID. In order to get the ID we have to do the following : Identify the user screen name of the profile. Get the User object of the profile using the get_user() method and the user name. From this object, fetch the id or id_str attribute present in it. Example 1: Consider the following profile : The screen name of the above mentioned profile is geeksforgeeks. # 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 screen name of the user screen_name = "geeksforgeeks" # fetching the user user = api.get_user(screen_name) # fetching the ID ID = user.id_str print("The ID of the user is : " + ID) Output : The ID of the user is : 57741058 Example 2: Consider the following profile : The screen name of the above mentioned profile is PracticeGfG. # the screen name of the user screen_name = "PracticeGfG" # fetching the user user = api.get_user(screen_name) # fetching the ID ID = user.id_str print("The ID of the user is : " + ID) Output : The ID of the user is : 4802800777 Last Updated : 18 Jun, 2020 Like Article Save Article Previous Python - API.followers() in Tweepy Next Python Tweepy - Getting the location of a user Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Python Tweepy - Getting the screen name of a user Python Tweepy - Getting the location of a user Python Tweepy - Getting the name of a user Python Tweepy – Getting the description of a user Python Tweepy – Getting the URL of a user Python Tweepy – Getting the number of followers of a user Python Tweepy – Getting the number of lists a user has been added to Python Tweepy – Getting the time when a user was created Python Tweepy – Getting the number of tweets a user has liked Python Tweepy – Getting the number of tweets a user has tweeted Like Y Yash_R Follow Article Tags : Python-Tweepy Python Practice Tags : python