McCandlish
A thin Ruby wrapper for NYT Article Search API Version 2. The name comes from McCandlish Phillips, "a tenacious reporter and a lyrical stylist" for The New York Times from 1952 to 1973.
THIS LIBRARY IS IN ALPHA STATE AND WILL CHANGE FREQUENTLY. DO NOT USE IT FOR ANYTHING, REALLY
Installation
Add this line to your application's Gemfile:
gem 'mccandlish'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mccandlish
Usage
You'll need an API key from The New York Times. Reading the Article Search V2 API docs wouldn't hurt, either. But once you have a key, you can get started like so:
require 'mccandlish'
# create a client
c = Mccandlish::Client.new('YOUR-API-KEY')
# retrieve API results for articles and blog posts mentioning Afghanistan from the Foreign Desk on May 26, 2013:
results = c.desk("Foreign").date("2013-05-26").query("Afghanistan").result
results.hits
=> 4
article = results.articles.first
=> #<Mccandlish::Article:0x007fca04897b20 @id="51a176ad46fdbf6c1db79139", @web_url="http://www.nytimes.com/2013/05/26/world/asia/in-afghan-transition-us-forces-take-a-step-back.html", @snippet="As the United States military moves into a support role in Afghanistan, a week spent with a brigade accompanying Afghan forces offered a direct look at the evolving training mission, for better or for worse.", ... @type_of_material="News", @word_count=1243>
article.headline
=> "In Afghan Transition, U.S. Forces Take a Step Back"
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request