Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If I call Twitter API to get all of my followers, how many calls to the API is that?

Tags:

twitter

If I want to download a list of all of my followers by calling the twitter API, how many calls is it? Is it one call or is it the number of followers I have?

Thanks!

Sriram

like image 836
Sriram Avatar asked Jan 27 '11 20:01

Sriram


People also ask

How many Tweets can be fetched using Twitter API?

Standard API v1. You can only post 300 Tweets or Retweets during a 3 hour period.

How do I get Twitter API followers?

So the answer to the original question: to get the follower count, ask for the public_metrics field in the User object, and access data. public_metrics. followers_count in the response.


2 Answers

If you just need the IDs of your followers, you can specify:

http://api.twitter.com/1/followers/ids.json?screen_name=yourScreenName&cursor=-1

The documentation for this call is here. This call will return up to 5,000 follower IDs per call, and you'll have to keep track of the cursor value on each call. If you have less than 5,000 followers, you can omit the cursor parameter.

If, however, you need to get the full details for all your followers, you will need to make some additional API calls.

I recommend using statuses/followers to fetch the follower profiles since you can request up to 100 profiles per API call.

When using statuses/followers, you just specify which user's followers you wish to fetch. The results are returned in the order that the followers followed the specified user. This method does not require authentication, however it does use a cursor, so you'll need manage the cursor ID for each call. Here's an example:

http://api.twitter.com/1/statuses/followers.json?screen_name=yourScreenName&cursor=-1

Alternatively, you can user users/lookup to fetch the follower profiles by specifying a comma-separated list of user IDs. You must authenticate in order to make this request, but you can fetch any user profiles you want -- not just those that are following the specified user. An example call would be:

http://api.twitter.com/1/users/lookup.json?user_id=123123,5235235,456243,4534563

So, if you had 2,000 followers, you would use just one call to obtain all of your follower IDs via followers/ids, if that was all you needed. If you needed the full profiles, you would burn 20 calls using statuses/followers, and you would use 21 calls when alternatively using users/lookup due to the additional call to followers/ids necessary to fetch the IDs.

Note that for all Twitter API calls, I recommend using JSON since it is a much more lightweight document format than XML. You will typically transfer only about 1/3 to 1/2 as much data over the wire, and I find that (in my experience) Twitter times-out less often when serving JSON.

like image 165
arcain Avatar answered Sep 17 '22 19:09

arcain


http://dev.twitter.com/doc/get/followers/ids

Reading this, it looks like it should only be 1 call since you're just pulling back an xml or json page. Unless you have more than 5000 followers, in which case you would have to make a call for each page of the paginated values.

like image 24
Joe Schubert Avatar answered Sep 17 '22 19:09

Joe Schubert