apitwittertwitter-follow

How to find a set of users are following or followed by another particular user using the Twitter API?


I want to know if there is any Twitter API via which I can get to know that if the set of users either following or followed by a particular user.

For example:

set_of_users are: { a,b,c}
particular user is: d

Then the result is a kind of

a:
following: true //(means a is following d)
friend: true //(means d is following a)

b:
following: false //(means b is not following d)
friend: false // (means

c:
following: false //(means c is not following d)
friend: true //(means c is following d)

Also, some API which tells it a, b, c, and d are all interconnected with each other as friend or follower?


Solution

  • You can use the friends/ids endpoint for friends:

    https://dev.twitter.com/rest/reference/get/friends/ids

    Use the followers/ids endpoint for followers:

    https://dev.twitter.com/rest/reference/get/followers/ids

    These return ids, which is good because it's fast and lets you pull in the whole list with a smaller number of queries.

    Once you have id's, use the users/lookup endpoint to pull in user data. It has a user_id parameter that you can use to gather multiple user records at a time, via a comma-separated list of id's:

    https://dev.twitter.com/rest/reference/get/users/lookup

    If you're new, you should visit the Twitter Documentation page and review Overview and Best Practices. These will answer a lot of questions you'll have. e.g. the type of querying you'll be doing will likely cause you to bump into rate limits, so reading up on that will save a lot of frustration later.

    https://dev.twitter.com/overview/documentation

    There isn't an API to manage graphs.