Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A thin Ruby client for The New York Times Newswire API
Ruby
tree: d13e8aa05f

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
Gemfile
LICENSE
README.rdoc
Rakefile
times_wire.gemspec

README.rdoc

.—–. _ .-. .-. _ `-. .-':_; : :.-.: ::_;

: :  .-.,-.,-.,-. .--.  .--.   : :: :: :.-..--.  .--. 
: :  : :: ,. ,. :' '_.'`._-.'  : `' `' ;: :: ..'' '_.'
:_;  :_;:_;:_;:_;`.__.'`.__.'   `.,`.,' :_;:_;  `.__.

Times Wire is a Ruby gem for interacting with The New York Times Newswire API (developer.nytimes.com/docs/read/times_newswire_api), which provides an up-to-the-minute stream of articles and blog posts published on NYTimes.com and The International Herald-Tribune.

News

  • Dec. 13, 2011: Version 0.5.0 released.

Installation

Install Times Wire as a gem:

gem install times_wire

For use in a Rails 3 application, put the following in your Gemfile:

gem "times_wire", "~> 0.5.0"

then issue the 'bundle install' command. Times Wire has been tested under Ruby 1.8.7.

Getting Started

You'll need an API Key from The New York Times Developer Network (developer.nytimes.com/). You can set your key as an environment variable (handy for running the test suite) or set it within a script or app:

TimesWire::Base.api_key = API_KEY

Times Wire allows users to retrieve news items by source ('nyt', 'iht' or 'all'), by section (such as 'world', 'u.s.', 'sports') or by NYTimes.com blog names (“The Caucus”, “FiveThirtyEight” or “At War”, for example). Building a request is easy. To retrieve the latest items from The New York Times:

@items = Item.latest('nyt')

By default, 20 items are returned, but you may change the limit in any request:

@items = Item.latest('iht', 15)

Limiting the items retrieved to a section of The Times is easy, too. For a list of sections, please see the Newswire API documentation (developer.nytimes.com/docs/read/times_newswire_api):

@items = Item.section('nyt', 'world')

Retrieving items from a single Times blog is similar:

@items = Item.blog_name('nyt', 'u.s.', 'The Caucus')

Future Development

On the list for future additions is the ability to limit requests to a specific number of hours and to support offsets. Patches, pull requests and feature ideas welcomed.

Authors

Derek Willis, dwillis@nytimes.com

Copyright

Copyright © 2011 Derek Willis. See LICENSE for details.

Something went wrong with that request. Please try again.