A ruby interface to the Open Federal Elections Commission (FEC) API. Returns data about election candidates and committees. Includes options to customize API requests.
Ruby Shell
Switch branches/tags
Clone or download
Pull request Compare This branch is 3 commits ahead, 2 commits behind debate-watch:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
mock/responses
spec
.gitignore
.rspec
CREDITS.md
Gemfile
LICENSE.txt
README.md
Rakefile
open_fec_api.gemspec

README.md

OpenFecApi

Gem Version

A ruby interface to the Open Federal Elections Commission (FEC) API. Returns data about election candidates and committees. Includes options to customize API requests.

Installation

gem install open_fec_api

Prerequisites

Obtain an API key.

Usage

client = OpenFecApi::Client.new("api_key_123")

candidates_response = client.candidates

candidate_response = client.candidate("P00003392")

committees_response = client.committees

committees_response = client.committee("C00571372")

Configuration Options

Request subsequent pages and avoid rate-limits.

options = {:page => 1, :per_page => 100}
response = client.candidates(options)

while response.page < response.pages do
  options.merge!({:page => response.page + 1})
  response = client.candidates(options)
end

Specify endpoint-specific parameters.

options = {:party => "DEM"}

response = client.candidates(options)

Contributing

Help establish and maintain full API endpoint coverage.

Browse existing issues or create a new issue to communicate bugs, desired features, etc.

After forking the repo and pushing your changes, create a pull request referencing the applicable issue(s).

Developing

git clone git@github.com:data-creative/open-fec-api-ruby.git
cd open-fec-api-ruby

Run bin/setup to install dependencies.

Obtain an API key and assign it to an environment variable called OPEN_FEC_API_KEY.

Testing

Run bundle exec rake or bundle exec rspec spec/ to run the tests.

Run bin/console for an interactive prompt to facilitate experiment.

Run bundle exec rake install to install the packaged gem onto your local machine for testing in other local projects.

Releasing

Update the version number in version.rb, then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.