Fetching All of My Followers and Write to Cache

103 views
Skip to first unread message

Vincent Edward Binua

unread,
Dec 7, 2015, 4:41:47 PM12/7/15
to Tumblr API Discussion
Hello guys!

I'm trying to fetch all of my followers using the PHP API ( $client->getBlogFollowers...). It allows both "limit" and "offset" as its parameters but no matter how much I changed the limit, it always just return exactly 20 results.

I'm sorry is this a bug or really just an enforced upper limit?

I'm trying to cache the results but to fetch all of it, I will have to call getBlogFollowers inside a loop until it retrieves all the data. For an account with 1000+ followers, that would mean looping about 50 times when it would  obviously be more efficient if I could stretch the limit to 1000 and get the results in just 1 call, or perhaps even 500 and make just 2.

However, when I tried fetching an acount of exactly 2,865 followers, I now get Rate Limit Exceeded error:

[06-Dec-2015 18:59:41 America/Chicago] PHP Fatal error:  Uncaught Tumblr\API\RequestException: [429]: Rate Limit Exceeded

Is looping the most efficient or perhaps the only way to fetch a thousand follower records? do I even need to consider the memory_limit or max_execution_time of php's ini settings?

I look forward to hearing from you! Thanks and much appreciated! :)

Michael Ceyko

unread,
Dec 14, 2015, 12:20:54 PM12/14/15
to Tumblr API Discussion
Hey Vincent,

The upper limit of 20 is intentional, so you will need to make numerous calls to actually retrieve all followers.

Regarding the 429 responses, we have lower rate limits set for requesting followers. You can see your current limit info by looking at the X-RateLimit-* headers. However, I would note that you should treat these only as informational, and not rely on their behavior or presence.

It's hard to say what your php.ini settings should be. You should be able to store the data for all those followers in a moderate amount of space, but may need additional execution time since you'll need to slow down your requests.

Regards,
-Mike Ceyko
Reply all
Reply to author
Forward
0 new messages