Difference between revisions of "C4LN 2012: Intro to the Twitter API"

From Code4Lib
Jump to: navigation, search
m (API Overview)
(working up a terse OAuth intro)
Line 27: Line 27:
 
* just like it says on the tin
 
* just like it says on the tin
 
* also trending topics
 
* also trending topics
 +
  
 
== Find your library ==
 
== Find your library ==
Line 46: Line 47:
  
 
Huzzah! You have your very own app!
 
Huzzah! You have your very own app!
 +
 +
=== A brief segue into OAuth ===
 +
 +
http://hueniverse.com/oauth/guide/intro/
 +
 +
OAuth metaphor: ''valet key'' to your car
 +
* lets an app act on behalf of a user when dealing with some service
 +
* lets a user give an app specific permissions to interact with a service on their behalf
 +
 +
Roles in OAuth:
 +
* consumer (client) -- ''your app''
 +
* service provider (server) -- ''Twitter''
 +
* user (resource owner) -- ''user''
 +
 +
 +
* receive OAuth keys
 +
** '''<tt>consumer_key</tt>'''
 +
** '''<tt>consumer_secret</tt>'''
  
  
 
=== Setup ===
 
=== Setup ===
  
* Details tab
+
 
 +
* tabs we're initially interested in: Details & Settings
 
* Settings tab:
 
* Settings tab:
 
** Application type:
 
** Application type:
Line 57: Line 77:
 
*** Read/Write/Access DMs
 
*** Read/Write/Access DMs
  
* receive OAuth keys
 
  
  

Revision as of 13:58, 24 May 2012

Presenter: Rick Scott - @shadowspar

API Overview


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


Creating a new app

First steps

Huzzah! You have your very own app!

A brief segue into OAuth

http://hueniverse.com/oauth/guide/intro/

OAuth metaphor: valet key to your car

  • lets an app act on behalf of a user when dealing with some service
  • lets a user give an app specific permissions to interact with a service on their behalf

Roles in OAuth:

  • consumer (client) -- your app
  • service provider (server) -- Twitter
  • user (resource owner) -- user


  • receive OAuth keys
    • consumer_key
    • consumer_secret


Setup

  • tabs we're initially interested in: Details & Settings
  • Settings tab:
    • Application type:
      • Read
      • Read/Write
      • Read/Write/Access DMs


Bot-specific stuff

  • create an account for your bot
  • authorize it on your app


Rules of Conduct

General Rules of the Road and TOS

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