Changes

C4LN 2012: Intro to the Twitter API

1,565 bytes added, 16:03, 24 May 2012
no edit summary
** 350/reqs per hour ''per signed-in account''
** 150/reqs per hour ''per anonymous IP address''
 
Things that '''do''' count against your limit
* pretty much anything that involves hitting the REST API: fetching tweets from your timeline, fetching user profiles, fetching your @-replies, getting a list of followers, whatever.
Things that '''do not''' count against your limit(but see below)* publishing status updates (sending tweets)* sending direct messages* following and unfollowing * checking the rate limit (by querying <tt>account/rate_limit_status</tt>** it can change, though nowadays it rarely does)** note also that you get three headers describing how quickly you're nomming through your ratelimit as part of every REST API reply, eg: *** <tt>X-RateLimit-Limit: 350</tt>*** <tt>X-RateLimit-Remaining: 350</tt>*** <tt>X-RateLimit-Reset: 1277485629</tt>  Other, service-specific limits* 1,000 tweets per day* 250 DMs per day* follow limits: +1,000 per day plus additional monitoring once you hit 2,000 followed users
=== Other gotchas ===
* '''Repeated tweets'''* failed reqs* You can't post a tweet that's an exact duplicate of any of your last few tweets. "Whoops! You already tweeted that!"* '''Failed requests'''** Twitter does crap out every now and again due to load or whatever other reason, so you need to watch for failures and catch the resulting exceptions. [500/502/503/504] * [https://dev.twitter.com/docs/error-codes-responses HTTP responses / error codes] ''are'' meaningful and you must honour them in your bot's behaviour. In particular:** '''400''' means you've hit the ratelimit on the REST API** '''420''' means you've hit the ratelimit on the Search or Streaming API ** '''403''' means you've hit update (tweeting) limit.   == Getting started on the code == Each Twitter API library is going to have its own way to get initialized and set up.  
22
edits