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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -