Followers, Friends and Relationships

From a user account perspective another user can either be a follower or a person that you you follow also described as friend.

Add Friend

// follow a user
await userClient.Users.FollowUserAsync("tweetinviapi");

// stop following a user
await userClient.Users.UnfollowUserAsync(42);

List Friends

List the users followed by a specific user.

var friendIds = await client.Users.GetFriendIdsAsync("tweetinviapi");
// or
var friendIdsIterator = client.Users.GetFriendIdsIterator(new GetFriendIdsParameters("tweetinviapi"));

Tweetinvi can fetch populated user objects by performing a set of additional requests. This iterator can retrieve up to 100 users per page.

var friends = await client.Users.GetFriendsAsync("tweetinviapi");
// or
var friendsIterator = client.Users.GetFriendsIterator(new GetFriendsParameters("tweetinviapi"));

List Followers

var followerIds = await client.Users.GetFollowerIdsAsync("tweetinviapi");
// or
var followerIdsIterator = client.Users.GetFollowerIdsIterator(new GetFollowerIdsParameters("tweetinviapi"));

Tweetinvi can fetch populated user objects by performing a set of additional requests. This iterator can retrieve up to 100 users per page.

var followers = await client.Users.GetFollowersAsync("tweetinviapi");
// or
var followersIterator = client.Users.GetFollowersIterator(new GetFollowersParameters("tweetinviapi"));

Outgoing Follower Requests

As an authenticated user following a private user, an outgoing follower request is sent to this private user.

var userIdsYouRequestedToFollow = await userClient.Users.GetUserIdsYouRequestedToFollowAsync();
// or
var userIdsYouRequestedToFollowIterator = userClient.Users.GetUserIdsYouRequestedToFollowIterator();

Tweetinvi can fetch populated user objects by performing a set of additional requests. This iterator can retrieve up to 100 users per page.

var usersYouRequestedToFollow = await userClient.Users.GetUsersYouRequestedToFollowAsync();
// or
var usersYouRequestedToFollowIterator = userClient.Users.GetUsersYouRequestedToFollowIterator();

Incoming Follower Requests

As a private user, any other user attempting to follow you will create an incoming request.

var userIdsRequestingFriendship = await userClient.Users.GetUserIdsRequestingFriendshipAsync();
// or
var userIdsRequestingFriendshipIterator = userClient.Users.GetUserIdsRequestingFriendshipIterator();

Tweetinvi can fetch populated user objects by performing a set of additional requests. This iterator can retrieve up to 100 users per page.

var userRequestingFriendship = await userClient.Users.GetUsersRequestingFriendshipAsync();
// or
var usersRequestingFriendshipIterator = userClient.Users.GetUsersRequestingFriendshipIterator();

Relationships

Details of relationships between 2 users.

var relationship = await userClient.Users.GetRelationshipBetweenAsync("source_user", "target_user");
// You can for example check if you
var canSourceSendDirectMessagesToTarget = relationship.CanSendDirectMessage;

List the relationships between the client’s authenticated user and a list of users.

var relationships = await userClient.Users.GetRelationshipsWithAsync(new [] { "target_user" });
var userSentAFollowingRequest = relationships[0].FollowingRequested;

Updated relationship state between the authenticated user and a target user.

await userClient.Users.UpdateRelationshipAsync(new UpdateRelationshipParameters("target_user")
{
    EnableRetweets = true,
    EnableDeviceNotifications = true
});