Reputation: 825
Using pip3 install twitter
for a small Python program to retrieve all user's tweets in total year.
utl = t.statuses.user_timeline(count = n, screen_name = name)
Got a error about rate limits, as it shows:
details: {'errors': [{'code': 88, 'message': 'Rate limit exceeded'}]}
After checking api docs, https://dev.twitter.com/rest/public/rate-limiting, but no idea how to fix it.
Hopefully, anyone could help. Thanks!
Upvotes: 0
Views: 12203
Reputation: 14304
The rate limit page is quite clear, you are restricted to making 180 calls per 15 minutes.
This gives you a few options.
sleep
in there to ensure it never exceeds the limit.The documentation for statuses/user_timeline says:
This method can only return up to 3,200 of a user’s most recent Tweets.
and
count
Specifies the number of tweets to try and retrieve, up to a maximum of 200 per distinct request.
So you can use count=200
to request all 3,200 statuses in just 16 API calls.
Upvotes: 7