A ruby interface to the Open Federal Elections Commission (FEC) API. Returns data about election candidates and committees. Includes options to customize API requests.
gem install open_fec_apiObtain an API key.
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")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)
endSpecify endpoint-specific parameters.
options = {:party => "DEM"}
response = client.candidates(options)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).
git clone git@github.com:data-creative/open-fec-api-ruby.git
cd open-fec-api-rubyRun bin/setup to install dependencies.
Obtain an API key and assign it to an environment variable called OPEN_FEC_API_KEY.
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.
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.