follower list

38 views
Skip to first unread message

Matt

unread,
Apr 12, 2018, 10:41:42 AM4/12/18
to Twitter Ruby Gem
Hi all,
There are few things i find very confusing right now.
I am trying to fetch all followers for few Twitter users.
1- When the user has few followers(less than a hundred), I never get the rate limit error.
When a user has many more followers (almost 800), I get almost every time the rate limit error.

2- How can we actually limit the number of followers fetched?
I am using:
@client.followers('screen_name', count: 200)
but the count argument is just ignored (I do receive many more followers).

Any help is welcome, thank you.
Matt

AdamT

unread,
Jul 9, 2018, 12:08:54 PM7/9/18
to Twitter Ruby Gem
I'm having the same problem. Any solution?

David Fisher

unread,
Jul 9, 2018, 3:48:23 PM7/9/18
to twitter-...@googlegroups.com
There isn't a great solution here unfortunately. The Twitter API these days is really hard to build something scalable on from what I've seen, and the follower graph has been a difficult vector for nearly 10 years. 

My best suggestion is to capture the follower IDs, and then fetch the individual followers using some sort of worker/queue system that can retry over time. 

You can capture the follower ids instead of the full objects with the `follower_ids` method: 


It's similar but only returns ID numbers instead of full profile information. 

I don't know why it isn't respecting the `count` offhand, except likely due to something weird with the API limits. 

David

--
You received this message because you are subscribed to the Google Groups "Twitter Ruby Gem" group.
To post to this group, send email to twitter-...@googlegroups.com.
Visit this group at https://groups.google.com/group/twitter-ruby-gem.

Ryan Williams

unread,
Jul 9, 2018, 8:28:45 PM7/9/18
to Twitter Ruby Gem
I think the count needs to be in an options hash?

@client.followers('screen_name', { count: 200 })

https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list

Ryan Williams

unread,
Jul 9, 2018, 10:23:01 PM7/9/18
to Twitter Ruby Gem
An additional note about this question

2- How can we actually limit the number of followers fetched?

Use the take to limit the fetching.

fetch_one_page = client.followers('screen_name', { count: 200 }).take(200)

Otherwise, if you enumerate the returned objection from client.followers, it will continue making calls until the rate limit is hit.

I also second David's recommendation to break this task into 2 API endpoints. Get the follower ids, then do a users/lookup with the collected ids.


On Thursday, April 12, 2018 at 7:41:42 AM UTC-7, Matt wrote:
Reply all
Reply to author
Forward
0 new messages