Git Product home page Git Product logo

sunlight-congress's Introduction

Sunlight::Congress

Build Status

The API this uses has been shutdown. Follow this post for more information.

This is a wrapper for the Sunlight Foundation's Congress API.

It is very much a work in progress, and only supports part of the API. Any assistance with implementing extra calls would be appreciated!

Installation

Add this line to your application's Gemfile:

gem 'sunlight-congress'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sunlight-congress

Usage

The first thing you need to do is set up an API key. You can apply for one here. They're free and have no usage limits.

Once you have your key:

require 'sunlight-congress'

Sunlight::Congress.api_key = "lolthisisnotarealkey"

Then, you can build various objects relating to the API. For example:

Sunlight::Congress::Legislator.by_zipcode("90210")
=> [#<Sunlight::Congress::Legislator:0x007fad4a2f67b0 @first_name="Henry"...

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

sunlight-congress's People

Contributors

achambers avatar isaacsanders avatar jamesprior avatar konklone avatar liliakai avatar rjsamson avatar seanknox avatar steveklabnik avatar timwhite47 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sunlight-congress's Issues

Require

I found that "require 'sunlight-congress'", which is mentioned in the readme, does not work, but "require 'sunlight/congress'" does work.

typo in README

You have require 'sunlight-congress' in the Usage section. I understand that is for the gem install, and easy to mix up while you're explaining it all.

That didn't work for me, I had to require 'sunlight/congress' in my app.

Is this a typo?

Make method calls chainable

As Joe and I were implementing the Vote functionality, we realized that in the API calls, queries can be chained. For example,

/hearings?query=environment&chamber=senate

Unfortunately, we only implemented each attribute of the vote object returned individually. It looks like the Bill class was implemented the same way. We weren't immediately sure of how to make the methods chainable, because we would have to build up the API call out of strings that the methods returned, etc...we just decided to punt on that for now. How were we thinking of doing that, or has anyone broached that topic?

General API approach discussion

So, a lot of the basic stuff has been done but I feel like there isn't really a decided way that the public facing API should look for things like filtering, querying, pagination etc etc.

There have been a couple of attempts but I haven't seen anything agreed upon. Can we come up with an agreed approach to this so that we can move forward?

I'm keen to contribute some code here but am unsure as to the best way forward.

Thoughts?

However Sunlight can be of service

Hi guys - I built Sunlight's Congress API, and stumbled upon your work here. I'm taken aback at the pace of development and the number of contributors - what got this started? In general, feel free to CC me on any ticket where I can be of help.

And of course, if there are any bugs or requests for the API itself, I use Github Issues to manage that as well.

Rubygems

Hey guys, just wondering when the next Ruby Gems version is being released?

Legislator methods

I'm doing this JumpStart Lab tutorial: http://tutorials.jumpstartlab.com/projects/eventmanager.html
It uses the Sunlight::Congress::Legislator.by_zipcode(arg) method and works fine.

For some reason, however, when I tried using the by_state method with the same syntax I got a NoMethodError "undefined method `by_state' for Sunlight::Congress::Legislator:Class". The same happened with the "by_bioguide_id" method, too.

Bill / Bill Search Discussion

So I noticed that a little bit of coverage for Bills has been merged in - I was working on something in parallel and wanted to see if the way I was approaching it was worth taking a look at. Since the results returned by Bill are rather lengthy and at times may vary, I thought it might be a good place to use a Hashie::Mash to wrap the results. What I've come up with so far looks like this: rjsamson@f407376 and can be used as follows:

# returns all bills matching 'health care' of bill_type 's'
bill = Sunlight::Congress::Bill.search("health care", :bill_type => 's')
bill.num_pages
#=> 50  # 50 pages of results
bill.count
#=> 991  # 991 results returned
bill.results[0].short_title
#=> "Health Care Bureaucrats Elimination Act"

That is just a few examples, but all results returned are available as methods under results.

Is there any interest in moving this direction?

Module structure

Just a question about the general module structure and assumptions. My first inclination was to move all external require statements into the congress.rb file and to take out the Sunlight::Congress module declaration from the top of legislator.rb. The goal would be to avoid repeating it at the top of every file, but it would require people to load the full api instead of being able to use just Sunlight::Congress::Legislator for example. Do you have a preference for how the module is structured, and if so is it the example in Legislator?

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.