Python – API.show_friendship() 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 the Twitter developer available easily for each user. These keys will help the API for authentication.
The show_friendship() method of the API class in Tweepy module is used to get the detailed relationship between two users.
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. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Syntax : API.show_friendship(source_id / source_screen_name, target_id / target_screen_name)
- source_id : specifies the ID of the user 1.
- source_screen_name : specifies the screen name of the user 1.
- target_id : specifies the ID of the user 2.
- target_screen_name : specifies the screen name of the user 2.
Returns : an object of the class Friendship
Example 1 : Analyzing friendships by using the screen names.
Is Twitter followed by TwitterIndia? : Yes Is Twitter following TwitterIndia? : No
Example 2 : Analyzing friendships by using the user IDs.
The screen name of user 1 is : ladygaga The screen name of user 2 is : ArianaGrande Is ladygaga followed by ArianaGrande? : Yes Is ladygaga following ArianaGrande? : No