22. What is ?
‣ REST API
‣ provides the “basic” Twitter functionality - tweet, follow, etc.
‣ all functions available on your timeline on twitter.com
‣ Search API
‣ real-time search index
‣ get “top tweets” / relevant search results
‣ Streaming API
‣ HTTP long-poll connection
‣ tweets come out of the system in real-time TM
22
23. The goals of
‣ To be ridiculously simple
‣ To be obvious
‣ To be self-describing
TM
23
24. Authenticating to
‣ OAuth 1.0a
‣ Signing “write” requests
‣ Give Twitter visibility into the stack
‣ Applications don’t have the user’s username / password
‣ User can change password at any time
‣ User is secure in knowing his/her password is not stored
‣ User can revoke permissions to app at any time
‣ User has one place to see which applications have access to their account
TM
24
25. twurl
‣ http://github.com/marcel/twurl
‣ Command line tool to interact with using OAuth
‣ Transparently handles OAuth signing against
‣ POST and GET data
‣ Trace requests
TM
25
26. Limits
‣ 175 API calls/hour using OAuth against api.twitter.com
‣ Unauthenticated it goes against the source IP address
‣ Authenticated it goes against the calling user
‣ “Natural” limits on
‣ number of tweets sent
‣ number of DMs sent
‣ number of followings / unfollowings
‣ Status limits
‣ No duplicate tweets
‣ No malware links in tweets TM
26
40. What you need to know
‣ All applications must be using OAuth for the REST API
‣ Streaming API will still support Basic Auth
‣ Search API has no auth
‣ OAuth key exchange for Open Source Applications
‣ Replace curl with twurl for debugging
http://dev.twitter.com/pages/auth_overview
http://github.com/marcel/twurl
TM
40
41. OAuth Methods
‣ Web must use three legged OAuth
‣ Desktop and mobile apps can also use out-of-band OAuth
‣ Some desktop and mobile apps will be considered for xAuth
TM
41
42. xAuth not XAuth
xAuth is OAuth
http://dev.twitter.com/pages/xauth
TM
42
50. /1/geo/search
‣ Find places to use in status updates
‣ Search by lat, long, IP or free-form name. Also search by attribute.
‣ Limit to poi, neighborhood, city, admin or country
‣ Find only places within another if desired
‣ Set a callback
‣ Use authorisation to bias ordering to the users location history
http://api.twitter.com/1/geo/search.json
TM
50
51. /1/geo/similar_places
‣ Find places to use in status updates
‣ Search by lat, long, free-form name. Also search by attribute.
‣ Find only places within another if desired
‣ Set a callback
‣ Search by attribute
http://api.twitter.com/1/geo/similar_places.json
TM
51
52. /1/geo/similar_places
‣ Must make this call before creating a place
‣ Returns a creation token
http://api.twitter.com/1/geo/similar_places.json
TM
52
53. /1/geo/reverse_geocode
‣ Find 20 places around the provided lat, long
‣ Limit to poi, neighborhood, city, admin or country
‣ Set a callback
‣ /geo/search is better
http://api.twitter.com/1/geo/reverse_geocode.json
TM
53
54. /1/geo/id/:id
‣ Information on a place
‣ :id from /geo/search methods
http://api.twitter.com/1/geo/id/:id
TM
54
55. /1/geo/place
‣ create a place
‣ must have
‣ name
‣ contained_within - place_id of another place, e.g. city
‣ token
‣ lat, long
‣ Set a callback
http://api.twitter.com/1/geo/place
TM
55
56. Create a place - the flow
‣ /1/geo/search
‣ show what’s nearby
‣ /1/geo/similar_places
‣ not found in search, find by name
‣ /1/geo/place
‣ still not found, create a new place
http://api.twitter.com/1/geo/place
TM
56
57. Use in search
‣ just pass place:place_id
http://search.twitter.com/search?q=place%3A247f43d441defc03
TM
57
58. Attributes {
"name": "Twitter HQ",
"polylines": [
],
"country_code": "US",
"country": "The United States of America",
"attributes": {
"street_address": "795 Folsom St",
"1166:id": "49547",
"623:id": "210176"
},
"url": "http://api.twitter.com/1/geo/id/247f43d441defc03.json",
"id": "247f43d441defc03",
}
TM
58
64. What is a Tweet?
The anatomy of a status update
TM
64
65. Dissecting a status object
The tweet's unique ID. These Text of the tweet.
IDs are roughly sorted & Consecutive duplicate tweets
developers should treat them are rejected. 140 character
as opaque (http://bit.ly/dCkppc). max (http://bit.ly/4ud3he).
DEPRECATED
{"id"=>12296272736,
"text"=>
"An early look at Annotations:
http://groups.google.com/group/twitter-api-announce/browse_thread/thread/fa5da2608865453", Tweet's
"created_at"=>"Fri Apr 16 17:55:46 +0000 2010", creation
"in_reply_to_user_id"=>nil, The ID of an existing tweet that date.
"in_reply_to_screen_name"=>nil, this tweet is in reply to. Won't
"in_reply_to_status_id"=>nil be set unless the author of the
The author's
The screen name &
"favorited"=>false,
user ID.
user ID of replied to referenced tweet is mentioned.
"truncated"=>false, Truncated to 140
characters. Only tweet author.
"user"=>
possible from SMS. The author's
{"id"=>6253282,
user name. The author's
"screen_name"=>"twitterapi",
The author's biography.
"name"=>"Twitter API",
screen name.
ded object can get out of sync.
"description"=>
"The Real Twitter API. I tweet about API changes, service issues and
e author of the tweet. This
happily answer questions about Twitter and our API. Don't get an answer? It's on my website.",
"url"=>"http://apiwiki.twitter.com", The author's
"location"=>"San Francisco, CA", URL.
The author's "location". This is a free-form text field, and
"profile_background_color"=>"c1dfee", there are no guarantees on whether it can be geocoded.
"profile_background_image_url"=>
TM
"http://a3.twimg.com/profile_background_images/59931895/twitterapi-background-new.png",
Rendering information
"profile_background_tile"=>false,
for the author. Colors
"profile_image_url"=>"http://a3.twimg.com/profile_images/689684365/api_normal.png",
are encoded in hex
"profile_link_color"=>"0000ff", 65
66. Dissecting a status object
The tweet's unique ID. These Text of the tweet.
IDs are roughly sorted & Consecutive duplicate tweets
developers should treat them are rejected. 140 character
as opaque (http://bit.ly/dCkppc). max (http://bit.ly/4ud3he).
DEPRECATED
{"id"=>12296272736,
"text"=>
"An early look at Annotations:
http://groups.google.com/group/twitter-api-announce/browse_thread/thread/fa5da2608865453", Tweet's
"created_at"=>"Fri Apr 16 17:55:46 +0000 2010", creation
"in_reply_to_user_id"=>nil, The ID of an existing tweet that date.
"in_reply_to_screen_name"=>nil, this tweet is in reply to. Won't
"in_reply_to_status_id"=>nil be set unless the author of the
The author's
The screen name &
"favorited"=>false,
user ID.
user ID of replied to referenced tweet is mentioned.
"truncated"=>false, Truncated to 140
characters. Only tweet author.
"user"=>
possible from SMS. The author's
{"id"=>6253282,
user name. The author's
"screen_name"=>"twitterapi",
The author's biography.
"name"=>"Twitter API",
screen name.
n get out of sync.
"description"=>
"The Real Twitter API. I tweet about API changes, service issues and
e tweet. This
happily answer questions about Twitter and our API. Don't get an answer? It's on my website.", TM
"url"=>"http://apiwiki.twitter.com", The author's
"location"=>"San Francisco, CA", URL.
The author's "location". This is a free-form text field, and
"profile_background_color"=>"c1dfee", there are no guarantees on whether it can be geocoded. 66
67. The screen name &
"favorited"=>false,
user ID.
The autho
referenced tweet is mentioned.
user ID of replied to
"truncated"=>false, Truncated to 140
characters. Only tweet author.
"user"=>
possible from SMS. The author's
{"id"=>6253282,
user name. The author's
"screen_name"=>"twitterapi",
The author's biography.
"name"=>"Twitter API",
screen name.
embedded object can get out of sync.
"description"=>
"The Real Twitter API. I tweet about API changes, service issues and
The author of the tweet. This
happily answer questions about Twitter and our API. Don't get an answer? It's on my website.",
"url"=>"http://apiwiki.twitter.com", The author's
"location"=>"San Francisco, CA", URL.
The author's "location". This is a free-form text field, and
"profile_background_color"=>"c1dfee", there are no guarantees on whether it can be geocoded.
"profile_background_image_url"=>
"http://a3.twimg.com/profile_background_images/59931895/twitterapi-background-new.png",
Rendering information
"profile_background_tile"=>false,
for the author. Colors
"profile_image_url"=>"http://a3.twimg.com/profile_images/689684365/api_normal.png",
are encoded in hex
"profile_link_color"=>"0000ff",
values (RGB).
"profile_sidebar_border_color"=>"87bc44", The creation date
"profile_sidebar_fill_color"=>"e0ff92", for this account.
"profile_text_color"=>"000000", Whether this account has
"created_at"=>"Wed May 23 06:01:13 +0000 2007", contributors enabled
"contributors_enabled"=>true, (http://bit.ly/50npuu). Number of
Number of tweets
"favourites_count"=>1, favorites this
this user has.
"statuses_count"=>1628, Number of user has.
"friends_count"=>13, users this user
"time_zone"=>"Pacific Time (US & Canada)", The timezone and offset is following.
"utc_offset"=>-28800, (in seconds) for this user.
"lang"=>"en", The user's selected
"protected"=>false, language.
"followers_count"=>100581,
"geo_enabled"=>true, Whether this user is protected
enabled (http://bit.ly/4pFY77).
"notifications"=>false, DEPRECATED
Whether this user has geo
or not. If the user is protected,
"following"=>true, in this context Number of
then this tweet is not visible
"verified"=>true}, Whether this user followers for
except to "friends".
"contributors"=>[3191321], has a verified badge. this user.
"geo"=>nil,
"coordinates"=>nil, DEPRECATED
"place"=> The contributors' (if any) user TM
The place ID IDs (http://bit.ly/50npuu).
{"id"=>"2b6ff8c22edd9576",
"url"=>"http://api.twitter.com/1/geo/id/2b6ff8c22edd9576.json",
"name"=>"SoMa", The URL to fetch a detailed 67
83. Streaming API
‣ A persistent connection to Twitter servers
‣ Get pushed a tweet that matches your predicate in “real-time”
‣ Server to server integrations
TM
83
84. Basic Usage
‣ Curl with Basic Auth or Twurl with OAuth
‣ One connection per username permitted
http://stream.twitter.com/1/statuses/sample.json
TM
84
85. Follow some users
‣ Curl with Basic Auth or Twurl with OAuth
‣ One connection per username permitted
‣ Pass up to 400 user_ids, comma seperated
http://stream.twitter.com/1/statuses/filter.json
TM
85
86. Filter by keyword
‣ Curl with Basic Auth or Twurl with OAuth
‣ One connection per username permitted
‣ Pass up to 200 keywords, comma seperated
‣ Example: Twitter will return statuses which contain: TWITTER,
twitter, "Twitter", twitter., #twitter and @twitter
http://stream.twitter.com/1/statuses/filter.json
TM
86
88. Streaming API - Default Level
‣ 200 x Keywords
‣ 400 x Follow userids
‣ 10 x 1-degree location boxes
TM
88
89. Streaming API - Access Levels
‣ Default
‣ Shadow - many followings
‣ Birddog - many more followings
‣ Restricted Track - many keywords
‣ Partner Track - many more keywords
‣ locRestricted - many locations
TM
89
90. Streaming API - Access Levels
‣ Default
‣ Shadow - many followings
‣ Birddog - many more followings
‣ Restricted Track - many keywords
‣ Partner Track - many more keywords
‣ locRestricted - many locations
‣ Firehose - all public statuses
TM
90
95. TA Keyfacts
BE ‣ Rate limits practically eliminated
‣ Hit the API for backfill of data
‣ Transition to userstream for real-time updates
‣ Social events streamed too
TM
95
96. TA
BE
More Info... Check out
bit.ly/userstreams-beta
bit.ly/userstreams-overview
TM
96