Two New Client Libraries: Times Wire and Campaign Cash

Thin client syndication of New York Times adds Times Newswire and Campaign Finance.  The world of modern publishing continues to change.
December 22, 2011, 12:08 PM

Two New Client Libraries: Times Wire and Campaign Cash

Now that we have 13 APIs to use, it's time for some client libraries, too. Our APIs get a lot of use internally and on NYTimes.com, often in small parts of a larger project or to power a single interactive. In most of these cases we've resorted to pulling data directly from endpoints rather than writing clients to help manage the task. But we're excited to release Ruby libraries that make it easier to interact with two of our APIs.

The new libraries are Times Wire and Campaign Cash. Times Wire is a thin client for The Times Newswire API, and Campaign Cash provides an interface to the Campaign Finance API. Both are available on GitHub right now, or by the usual Ruby gem install methods.

Times Wire allows developers to dip into the fire hose of content that the Newswire API contains: the articles and blog posts published throughout each day by Times staffers and contributors, in addition to content from The International Herald Tribune. It also allows users to retrieve content from a single section or from an individual blog on NYTimes.com. Newswire items offer a rich collection of metadata, including related stories and images where available.

Fetching the most recent Times stories and blog posts is as easy as setting the API key and then using the following command:

@items = Item.latest('nyt')

Limiting stories to The Times's World section is similar:

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

Other examples are on the README page and in the tests. Times Wire has been tested under Ruby versions 1.8.7 and 1.9.2.

Campaign Cash offers a way to find and filter data on candidates and committees registered with the Federal Election Commission. It has classes representing candidates, committees, filings, committee contributions and independent expenditures.

Users can find details on candidates and committees by searching by name or by providing the F.E.C.-issued identifiers. The following method searches for candidates with the last name of "Gillibrand" in the 2012 election cycle, and returns an array with a single object:

ree-1.8.7-2011.03 :006 > gillibrand = Candidate.search("Gillibrand", 2012)
 => [#<CampaignCash::Candidate:0x101c34680 @name="GILLIBRAND, KIRSTEN ELIZABETH", @party="DEM", @state="NY", @district=0, @committee_id="C00413914", @office="senate", @id="S0NY00410">] 

Many of the response attributes can be used to make additional calls from the gem. In the above example, a user could fetch more information about Kirsten Gillibrand by using Candidate.find:

ree-1.8.7-2011.03 :017 > Candidate.find(gillibrand.first.id, 2012)
 => #<CampaignCash::Candidate:0x101b94c48 @name="GILLIBRAND, KIRSTEN ELIZABETH", @mailing_address="52 EAST ROAD", @begin_cash=613761.0, @party="DEM", @candidate_loans=nil, @total_receipts=8380990.0, @date_coverage_from="2011-01-01", @status="I", @mailing_city="BRUNSWICK", @debts_owed=nil, @state="NY", @district=0, @total_from_pacs=1105480.0, @mailing_zip="12180", @date_coverage_to="2011-09-30", @committee_id="C00413914", @total_refunds=17891.0, @office="senate", @total_from_individuals=6925900.0, @id="S0NY00410", @mailing_state="NY", @end_cash=7154380.0, @fec_uri="http://query.nictusa.com/cgi-bin/fecimg/?S0NY00410", @total_disbursements=1840370.0, @total_contributions=8031380.0>

Campaign Cash has access to all of the data from the API except for thepresidential candidate-specific responses; those will be added in a future release. It does contain summary and detail information for presidential candidates and committees, just as it does for House and Senate candidates. Data contained in the API about candidates and committees is updated weekly, while electronic filings and independent expenditures are updated daily. The gem has been tested under Ruby version 1.8.7 and 1.9.2.

We're always interested in how our APIs are being used, and the same goes for these clients. So please let us know if you make something with them, or fork the repositories on GitHub and help us make them easier for everyone to use.

Enhanced by Zemanta

Resources

Recent Assets

  • purple-car.png
  • IGEL_3rdPartyDatabase_sm.jpg
  • hp-t620.png
  • screencap016(526 x 702).jpg
  • Top100Logo2013.png
  • DieterTolksdorf2_web.jpg
  • hp-portfolio.png
  • mt41 (2).png
  • mt41 (1).png
  • IGEL_Gebaeude_small.jpg

About this Entry

This page contains a single entry by Staff published on December 22, 2011 2:28 PM.

Thin Client for QSR Domino's Pizza in India from VXL was the previous entry in this blog.

Heavy Storage for Thin Clients is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Categories

Monthly Archives