python - How to resolve twitter api rate limit? -


using pip3 install twitter small python program retrieve user's tweets in total year.

utl = t.statuses.user_timeline(count = n, screen_name = name) 

got error rate limits, shows:

details: {'errors': [{'code': 88, 'message': 'rate limit exceeded'}]}

after checking api docs, https://dev.twitter.com/rest/public/rate-limiting, no idea how fix it.

hopefully, help. thanks!

the rate limit page quite clear, restricted making 180 calls per 15 minutes.

this gives few options.

  • throttle code. put sleep in there ensure never exceeds limit.
  • use api options maximum amount of data in shortest amount of api calls.

the documentation statuses/user_timeline says:

this method can return 3,200 of user’s recent tweets.

and

count specifies number of tweets try , retrieve, maximum of 200 per distinct request.

so can use count=200 request 3,200 statuses in 16 api calls.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -