Steve Agalloco, Erik Michaels-Ober, and Jeremy Haile have delivered a major update to Intridea’s TweetStream (2.0.0) gem, which gives you access to the Twitter Streaming API.

One of the biggest updates in this version is the switch to OAuth as the default authentication method. This was necessary because Userstreams and Site Streams exclusively work on OAuth. You can still use basic authentication, but both Twitter and TweetStream strongly encourage you to switch, so you can enjoy the new features. Don’t worry, it’s simple.

The gem itself is built on top of em-twitter, which is an EventMachine client for the Twitter Streaming API.

Getting up and running couldn’t be easier:

require 'tweetstream'

TweetStream.configure do |config|
  config.consumer_key  = "123456789"
  config.consumer_secret = "abcdefghijklmnopqrstuvwxyz"
  config.oauth_token = "123456789"
  config.oauth_token_secret = "abcdefghijklmnopqrstuvwxyz"
  config.auth_method = :oauth
end

TweetStream::Client.new.userstream do |status|
  puts "#{status.user.screen_name}: #{status.text}"
end

t, a command line interface for twitter (covered in a previous article), is also built on top of the TweetStream gem.

Head on over to GitHub to view the source code and browse the documentation.


Have comments? Send a tweet to @TheChangelog on Twitter.

Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.