Twitter User Streams Api

Preview:

DESCRIPTION

My quickly-hacked together presentation for Warblecamp on the new Twitter User Streams API.

Citation preview

Let’s Hack the Twitter User Streams API

@aral #warblecamp

BETA

Client-side use only

(Continue to use stream.twitter.com for

service to serviceintegrations.)

John Kalucki (Twitter Dev Mailing List, May 3)

JSON only

1) If the key "text" exists, this is a status2) If the key "delete" exists, this is a status deletion3) If the key "scrub_geo" exists, this is a geo-tagging deletion message4) If the key "direct_message" exists, this is a direct message5) If the key "event" exists, this is a social event

Mark McBride (Twitter Dev Mailing List, May 3)

oAuth support live (as of May 7th,

2010)

Fully hydrated objects (as of May

3rd)

1) The user's latest status may not be included2) The user's status count may not be included3) The user's favorites count may not be included

Mark McBride (Twitter Dev Mailing List, May 3)

{"created_at"=>"Mon May 03 17:42:55 +0000 2010", "target_object"=> {"coordinates"=>nil,  "truncated"=>false,  "created_at"=>"Sun Jun 28 23:10:35 +0000 2009",  "favorited"=>false,  "contributors"=>nil,  "text"=>"looking at cricket eyes!",  "id"=>4,  "geo"=>nil,  "in_reply_to_user_id"=>nil,  "source"=>"web",  "place"=>nil,  "user"=>   {"profile_background_tile"=>false,    "name"=>"Ray",    "profile_sidebar_border_color"=>"87bc44",    "profile_sidebar_fill_color"=>"e0ff92",    "location"=>nil,    "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",    "profile_image_url"=>"/images/default_profile_4_normal.png",    "profile_link_color"=>"0000ff",    "contributors_enabled"=>false,    "url"=>nil,    "favourites_count"=>1,    "id"=>4,    "utc_offset"=>-21600,    "profile_text_color"=>"000000",    "protected"=>true,    "lang"=>"en",    "followers_count"=>3,    "notifications"=>nil,    "verified"=>false,    "description"=>nil,    "profile_background_color"=>"9ae4e8",    "geo_enabled"=>false,    "time_zone"=>"Saskatchewan",    "profile_background_image_url"=>"/images/themes/theme1/bg.png",    "statuses_count"=>1,    "friends_count"=>3,    "screen_name"=>"ray",    "following"=>nil},  "in_reply_to_screen_name"=>nil,  "in_reply_to_status_id"=>nil}, "event"=>"favorite", "target"=> {"profile_background_tile"=>false,  "name"=>"Ray",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>nil,  "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",  "profile_image_url"=>"/images/default_profile_4_normal.png",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>1,  "id"=>4,  "utc_offset"=>-21600,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>3,  "notifications"=>nil,  "verified"=>false,  "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

    "profile_sidebar_fill_color"=>"e0ff92",    "location"=>nil,    "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",    "profile_image_url"=>"/images/default_profile_4_normal.png",    "profile_link_color"=>"0000ff",    "contributors_enabled"=>false,    "url"=>nil,    "favourites_count"=>1,    "id"=>4,    "utc_offset"=>-21600,    "profile_text_color"=>"000000",    "protected"=>true,    "lang"=>"en",    "followers_count"=>3,    "notifications"=>nil,    "verified"=>false,    "description"=>nil,    "profile_background_color"=>"9ae4e8",    "geo_enabled"=>false,    "time_zone"=>"Saskatchewan",    "profile_background_image_url"=>"/images/themes/theme1/bg.png",    "statuses_count"=>1,    "friends_count"=>3,    "screen_name"=>"ray",    "following"=>nil},  "in_reply_to_screen_name"=>nil,  "in_reply_to_status_id"=>nil}, "event"=>"favorite", "target"=> {"profile_background_tile"=>false,  "name"=>"Ray",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>nil,  "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",  "profile_image_url"=>"/images/default_profile_4_normal.png",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>1,  "id"=>4,  "utc_offset"=>-21600,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>3,  "notifications"=>nil,  "verified"=>false,  "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

    "description"=>nil,    "profile_background_color"=>"9ae4e8",    "geo_enabled"=>false,    "time_zone"=>"Saskatchewan",    "profile_background_image_url"=>"/images/themes/theme1/bg.png",    "statuses_count"=>1,    "friends_count"=>3,    "screen_name"=>"ray",    "following"=>nil},  "in_reply_to_screen_name"=>nil,  "in_reply_to_status_id"=>nil}, "event"=>"favorite", "target"=> {"profile_background_tile"=>false,  "name"=>"Ray",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>nil,  "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",  "profile_image_url"=>"/images/default_profile_4_normal.png",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>1,  "id"=>4,  "utc_offset"=>-21600,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>3,  "notifications"=>nil,  "verified"=>false,  "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

   "profile_sidebar_fill_color"=>"e0ff92",  "location"=>nil,  "created_at"=>"Mon Apr 12 00:00:00 +0000 2010",  "profile_image_url"=>"/images/default_profile_4_normal.png",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>1,  "id"=>4,  "utc_offset"=>-21600,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>3,  "notifications"=>nil,  "verified"=>false,  "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

   "description"=>nil,  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Saskatchewan",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>3,  "screen_name"=>"ray",  "following"=>nil}, "source"=> {"profile_background_tile"=>false,  "name"=>"Jack",  "profile_sidebar_border_color"=>"87bc44",  "profile_sidebar_fill_color"=>"e0ff92",  "location"=>"San Francisco",  "created_at"=>"Wed Apr 28 00:00:00 +0000 2010",  "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

   "profile_image_url"=>   "http://s3.amazonaws.com/twitter_development/profile_images/2/jack_normal.jpg",  "profile_link_color"=>"0000ff",  "contributors_enabled"=>false,  "url"=>nil,  "favourites_count"=>0,  "id"=>3,  "utc_offset"=>-28800,  "profile_text_color"=>"000000",  "protected"=>true,  "lang"=>"en",  "followers_count"=>2,  "notifications"=>nil,  "verified"=>false,  "description"=>"love, love",  "profile_background_color"=>"9ae4e8",  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

  "geo_enabled"=>false,  "time_zone"=>"Pacific Time (US & Canada)",  "profile_background_image_url"=>"/images/themes/theme1/bg.png",  "statuses_count"=>1,  "friends_count"=>2,  "screen_name"=>"jack",  "following"=>nil}}

{

 "target_object"=>  "user"=>   {    "name"=>"Ray",   },

 "event"=>"favorite", "target"=> {  "name"=>"Ray",},

 "source"=> {  "name"=>"Jack",}

Direct Messages

{"direct_message"=>

 {"created_at"=>"Wed Apr 28

14:56:31 +0000 2010", //...

  "sender_screen_na

me"=>"user1",  "sender"=>

Resources

Earlybird sample app:

http://github.com/zbowling/earlybird/

earlybird.rb -c consumer_token -s consumer_secret -a access_token -S access_secret [-d] [-f] [-t key,words] [-u url] [-h host]options:   -c   --consumer_token   consumer token  -s   --consumer_secret  consumer secret  -a   --access_token     access token  -S   --access_secret    access secret  -r                      show in reply too (takes a lot of API requests)  -d                      debug mode, read json from stdin  -f                      filter out @replies from users you don't follow  -g                      growl notifications for new tweets  -t                      track keywords separated by commas.  -u                      userstream path. Default: /2b/user.json  -h                      userstream hostname: Default: betastream.twitter.com

Useful clients:Tweetstream

(Ruby)intridea/tweetstrea

m

(See @tommorris’s session for more

info)