A simple Summize client for Ruby.

Access the Summize API from your Ruby code.

Usage

Require the gem.

require 'summize'

Set up a Summize::Client. Name your client (a.k.a. 'user agent') to something meaningful, such as your app's name. This helps Summize answer any questions about your use of the API.

@client = Summize::Client.new 'politweets'

Request tweets by calling the query method of your client. It takes either a String or a Hash of arguments.

@tweets = @client.query 'twitter search'

The String form uses the default Summize behavior, which in this example finds tweets containing both "twitter" and "search". It is identical to the more verbose, explicit version:

@tweets = @client.query :q => 'twitter search'

Use Summize's query operators with the :q key to access the following behavior:

OperatorFinds tweets...
:q => 'twitter search'containing both "twitter" and "search". This is the default operator.
:q => '"happy hour"'containing the exact phrase "happy hour".
:q => 'obama OR hillary'containing either "obama" or "hillary" (or both).
:q => 'beer -root'containing "beer" but not "root".
:q => '#haiku'containing the hashtag "haiku".
:q => 'from:alexiskold'sent from person "alexiskold".
:q => 'to:techcrunch'sent to person "techcrunch".
:q => '@mashable'referencing person "mashable".
:q => 'superhero since:2008-05-01'containing "superhero" and sent since date "2008-05-01" (year-month-day).
:q => 'ftw until:2008-05-03'containing "ftw" and sent up to date "2008-05-03".
:q => 'movie -scary :)'containing "movie", but not "scary", and with a positive attitude.
:q => 'flight :('containing "flight" and with a negative attitude.
:q => 'traffic ?'containing "traffic" and asking a question.
:q => 'hilarious filter:links'containing "hilarious" and linking to URLs.

Foreign Languages

The Summize API supports foreign languages, accessible via the :lang key. Use the ISO 639-1 codes as the value:

@tweets = @client.query :q => 'programmé', :lang => 'fr'

Gotchas

  • Searches are case-insenstive.
  • The "near" operator available in the Summize web interface is not available via the API. You must geocode before making your Summize API call.
  • Searching for a positive attitude :) returns tweets containing the text :), =), :D, and :-)

Authors

Written by Dustin Sallings ([email protected]), forked by Dan Croak ([email protected]).

Resources

License

MIT License, same terms as Ruby.