Giter Club home page Giter Club logo

transparency-data's Introduction

TransparencyData.com Ruby Wrapper

By Wynn Netherland, Jeremy Hinegardner, and Luigi Montanez

Before using this library, please read the official TransparencyData.com API documentation. Query parameters and return formats are described there.

Setup

Get an API key from Sunlight Labs.

Required gems:

  • monster_mash
  • hashie

After 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'
end

Optionally, 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 for all parameters you can send in, and the schema 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}"
end

As 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']})

Contributing

Required gems for running tests:

  • mg
  • shoulda
  • jnunemaker-matchy
  • mocha
  • fakeweb
  • vcr

Run the test suite:

rake test

transparency-data's People

Contributors

luigi avatar pengwynn avatar

Stargazers

Leah Nelson avatar Angus H. avatar Bilal Sheikh avatar  avatar  avatar blake avatar Dee Wu avatar Paul Franzen avatar Darek Miskiewicz avatar Prabode Weebadde avatar Pete Skomoroch avatar Jim Gilliam avatar Jeremy Hinegardner avatar Rupak Ganguly avatar Sinclair Bain avatar Nikolay Kolev avatar Derek Willis avatar  avatar  avatar

Watchers

Jeremy Hinegardner avatar James Cloos avatar

transparency-data's Issues

gem is deprecated but will still work

Tried to get use this gem recently but it didn't work. Figured out that if you change to older dependencies it will still work.
Just run:

gem install typhoeus --version '= 0.1.23'
gem install monster_mash --version '= 0.1.0'

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.