Simple ruby wrapper for The New York Times Campaign Finance API. You'll need an API key.
gem install campaign_cash
require 'rubygems' require 'campaign_cash'
You'll want to set your API key as an environment variable in order to run the tests. Otherwise, you'll need to set it like so:
Base.api_key = YOUR_API_KEY
Currently there are methods to support retrieving candidates, committees, electronic filings, committee contributions and independent expenditures. Almost every method requires at least one parameter, the election cycle. Some examples (provided you've done include CampaignCash):
Candidate.find("H4NY07011", 2012) # find Gary Ackerman's details for the 2012 cycle Committee.search("Growth", 2012) # find all committees in the 2012 cycle with the word 'Growth' in the name. Candidate.search("Udall", 2010) # find all candidates in the 2010 cycle with the name 'Udall' Filing.today # find all the electronic filings made today. Contribution.find("C00458588",2010,"H0NC02059") # find all contributions by the committee to the candidate in the 2010 cycle. IndependentExpenditure.candidate("P60003654", 2012) # find independent expenditures about Newt Gingrich in the 2012 cycle.
Check out the tests for further examples.
Note on Patches/Pull Requests
Fork the project.
Make your feature addition or bug fix.
Add tests for it. This is important so I don't break it in a future version unintentionally.
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
Send me a pull request. Bonus points for topic branches.
Derek Willis, email@example.com
Copyright © 2011 The New York Times Company. See LICENSE for details.