Identifying rate-limited resource (error code 88)


#1

I’m using the python library Tweepy to make GET requests of the Twitter API.

When I run my program - which gets all friends/ids, then gets user/timeline for the 300 most-followed - I get this error from Tweepy:

{"errors":[{"message":"Rate limit exceeded","code":88}]}

However, when I printed out the rate limit status:

api.rate_limit_status()

…and check the “remaining” attribute of each resource, not a single resource has reached the end of remaining requests.
Example:

'/friends/ids': {'reset': 1416804275, 'limit': 15, 'remaining': 14}

How can I find out which rate limit I’m hitting when checking the rate limit status doesn’t reveal anything?

Thank you!


#2

It sounds like you are calling user/timeline 300 times? wouldn’t that cause you to hit a limit?


#3

You’re right, that’s something I have to watch out for. But, I get the “rate limit exceeded” error well before 300 calls – after around 50. I know this because get_timeline (which sends GET user/timeline through Tweepy) prints to the console after each request, and it printed only 47 times before I got the error. Here’s the code where I call get_timeline. (MAX_NUM_FRIENDS is set to 300).

            if len(friendlist) > user.MAX_NUM_FRIENDS:
	    friendlist = get_top_influencers(user.MAX_NUM_FRIENDS)

	    friend_scores = {}

	    for friend in friendlist:
	        timeline = friend.get_timeline(friend.USER_ID, friend.MAX_NUM_TWEETS)
	        hashtag_count = friend.count_hashtags(timeline)
	        friend.SCORE = friend.score(hashtag_count)
	        friend_scores[friend.SCREEN_NAME] = friend.SCORE

Which prints something like this:

get timeline api call
processing tweet
processing tweet
processing tweet
Scoring

(Processing the tweet simply involves counting hashtags and checking them against a database - no further API requests made.)

Please let me know what you think!