Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pengwynn/transparency-data
Wrapper for the Sunlight Transparency Data API
https://github.com/pengwynn/transparency-data
Last synced: 3 months ago
JSON representation
Wrapper for the Sunlight Transparency Data API
- Host: GitHub
- URL: https://github.com/pengwynn/transparency-data
- Owner: pengwynn
- License: mit
- Created: 2010-05-07T04:48:43.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-01-07T18:49:28.000Z (about 14 years ago)
- Last Synced: 2024-10-14T14:52:27.235Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 468 KB
- Stars: 19
- Watchers: 2
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# TransparencyData.com Ruby Wrapper
By Wynn Netherland, Jeremy Hinegardner, and Luigi Montanez
Before using this library, please read the official [TransparencyData.com API documentation](http://transparencydata.com/api/). Query parameters and return formats are described there.
## Setup
Get an API key from [Sunlight Labs](http://services.sunlightlabs.com/).
Required gems:
* monster_mash
* hashieAfter a `gem install transparency_data`, you can do:
require 'transparency_data'
TransparencyData.api_key = 'YOUR_KEY_HERE'
Within a Rails app, create a `config/initializers/transparency_data.rb` and stick this in:TransparencyData.configure do |config|
config.api_key = 'YOUR_KEY_HERE'
endOptionally, you can set `TransparencyData.api_domain` if you don't want to hit the production API at `transparencydata.com`.
## Usage
See the official [API docs](http://transparencydata.com/api/) for all parameters you can send in, and the [schema docs](http://transparencydata.com/docs/) for what you get back:
contributions = TransparencyData::Client.contributions(:contributor_ft => 'steve jobs')
contributions.each do |contribution|
puts "Amount: #{contribution.amount}"
puts "Date: #{contribution.date}"
end
lobbyings = TransparencyData::Client.lobbying(:client_ft => "apple inc")
lobbyings.each do |lobbying|
puts "Amount: #{lobbying.amount}"
puts "Year: #{lobbying.year}"
endAs described in the API docs, the TransparencyData.com API supports a special syntax as the parameter value for specifying ranges and sets on amount, cycle, year, and date. You can either pass in strings, or use a more Rubyish approach:
# contributions with an amount greater than or equal to $1000
TransparencyData::Client.contributions(:contributor_ft => 'steve jobs', :amount => {:gte => 1000})# contributions with an amount less than or equal to $500
TransparencyData::Client.contributions(:contributor_ft => 'bill gates', :amount => {:lte => 500})
# contributions in the 2006 or 2008 cycle
TransparencyData::Client.contributions(:contributor_ft => 'eric schmidt', :cycle => [2006,2008]})# contributions to Obama made between in Q1 2008
TransparencyData::Client.contributions(:recipient_ft => 'barack obama',
:date => {:between => ['2008-01-01','2008-03-31']})
## ContributingRequired gems for running tests:
* mg
* shoulda
* jnunemaker-matchy
* mocha
* fakeweb
* vcrRun the test suite:
rake test