Difference between revisions of "C4LN 2012: Intro to the Twitter API"
From Code4Lib
Shadowspar (Talk | contribs) |
Shadowspar (Talk | contribs) |
||
Line 5: | Line 5: | ||
* https://dev.twitter.com/ is API central. | * https://dev.twitter.com/ is API central. | ||
** other useful things linked therefrom: [https://dev.twitter.com/status API Status], [https://dev.twitter.com/issues API Known Issues], blog & discussion | ** other useful things linked therefrom: [https://dev.twitter.com/status API Status], [https://dev.twitter.com/issues API Known Issues], blog & discussion | ||
− | * https://dev.twitter.com/docs is the main documentation area | + | * '''https://dev.twitter.com/docs is the main documentation area''' |
** you'll find yourself spending a lot of time here =) | ** you'll find yourself spending a lot of time here =) | ||
Line 11: | Line 11: | ||
=== Parts === | === Parts === | ||
− | |||
* the '''REST API''' | * the '''REST API''' | ||
− | |||
− | |||
* the '''Streaming API''' | * the '''Streaming API''' | ||
− | |||
− | |||
* the '''Search API''' | * the '''Search API''' | ||
− | |||
− | |||
+ | ==== REST API ==== | ||
+ | * query→response based access | ||
+ | * the mainstay of the API; the first part of it you'll want to be concerned with, and the part you'll likely use most | ||
+ | |||
+ | ==== Streaming API ==== | ||
+ | * aka ''drinking from the firehose'' =) | ||
+ | * persistent connection | ||
+ | * push-based communication w/ v.high ratelimit (1% of ''all tweets'') | ||
+ | |||
+ | ==== Search API ==== | ||
+ | * just like it says on the tin | ||
+ | * also trending topics | ||
== Find your library == | == Find your library == | ||
− | https://dev.twitter.com/docs/twitter-libraries | + | https://dev.twitter.com/docs/twitter-libraries has a good list |
* Perl: [http://search.cpan.org/dist/Net-Twitter Net::Twitter] | * Perl: [http://search.cpan.org/dist/Net-Twitter Net::Twitter] | ||
Line 35: | Line 40: | ||
== Creating a new app == | == Creating a new app == | ||
+ | === First steps === | ||
* https://dev.twitter.com/apps/new | * https://dev.twitter.com/apps/new | ||
* sign in with your twitter account | * sign in with your twitter account | ||
+ | * fill out basic info about your app | ||
+ | * agree to be a good citizen, as detailed below | ||
− | + | Huzzah! You have your very own app! | |
− | + | ||
− | == | + | === Setup === |
+ | |||
+ | * Details tab | ||
+ | * Settings tab: | ||
+ | ** Application type: | ||
+ | *** Read | ||
+ | *** Read/Write | ||
+ | *** Read/Write/Access DMs | ||
+ | |||
+ | * receive OAuth keys | ||
+ | |||
+ | |||
+ | == Bot-specific stuff == | ||
+ | |||
+ | * create an account for your bot | ||
+ | * authorize it on your app | ||
+ | |||
== Rules of Conduct == | == Rules of Conduct == | ||
− | |||
− | === General TOS === | + | === General Rules of the Road and TOS === |
+ | |||
+ | * https://dev.twitter.com/terms/api-terms | ||
+ | * https://support.twitter.com/articles/76915 - automation rules and best practices | ||
+ | |||
+ | === Rate limits === | ||
+ | |||
+ | * | ||
+ | |||
+ | === Other gotchas === | ||
+ | |||
+ | * Repeated tweets | ||
Revision as of 12:25, 24 May 2012
Presenter: Rick Scott - @shadowspar
Contents
API Overview
- https://dev.twitter.com/ is API central.
- other useful things linked therefrom: API Status, API Known Issues, blog & discussion
- https://dev.twitter.com/docs is the main documentation area
- you'll find yourself spending a lot of time here =)
Parts
- the REST API
- the Streaming API
- the Search API
REST API
- query→response based access
- the mainstay of the API; the first part of it you'll want to be concerned with, and the part you'll likely use most
Streaming API
- aka drinking from the firehose =)
- persistent connection
- push-based communication w/ v.high ratelimit (1% of all tweets)
Search API
- just like it says on the tin
- also trending topics
Find your library
https://dev.twitter.com/docs/twitter-libraries has a good list
- Perl: Net::Twitter
- Python: tweepy and many others
- Ruby: twitter rubygem and others
Creating a new app
First steps
- https://dev.twitter.com/apps/new
- sign in with your twitter account
- fill out basic info about your app
- agree to be a good citizen, as detailed below
Huzzah! You have your very own app!
Setup
- Details tab
- Settings tab:
- Application type:
- Read
- Read/Write
- Read/Write/Access DMs
- Application type:
- receive OAuth keys
Bot-specific stuff
- create an account for your bot
- authorize it on your app
Rules of Conduct
General Rules of the Road and TOS
- https://dev.twitter.com/terms/api-terms
- https://support.twitter.com/articles/76915 - automation rules and best practices
Rate limits
Other gotchas
- Repeated tweets
Example
http://twitter.com/inetkami https://github.com/rickscott/inetkami
Other Miscellany
- t, a Ruby command-line interface to the Twitter API