百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

govkit

> 编程语言
开源

针对网络中各种开放政府 API 的 Ruby 封装

182 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

针对网络中各种开放政府 API 的 Ruby 封装

Govkit

Govkit is a Ruby gem that provides simple access to US open government APIs around the web, including:

  • OpenCongress, which has an API for federal bills, votes, people, and news and blog coverage
  • The Open States project, which has a RESTful API for accessing data about state legislators, bills, votes, etc.
  • Project Vote Smart, which has an API with congressional addresses, etc.
  • Follow The Money, whose API reveals campaign contribution data for state officials.
  • TransparencyData API (campaign contributions only)

Installation

From gemcutter:

gem install govkit

Setup

Add govkit to your environment.rb or Gemfile

Run rails generate govkit (Rails 3.x) or script/generate govkit (Rails 2.x) to copy a config file into config/initializers/govkit.rb. You will need to add your API keys to this config file.

Outside of Rails you can configure your API keys like so:

>> GovKit.configure do |config|
>>   config.sunlight_apikey   = 'YOUR_SUNLIGHT_API_KEY'
>>   config.votesmart_apikey  = 'YOUR_VOTESMART_API_KEY'
>>   config.ftm_apikey        = 'YOUR_FTM_API_KEY'
>> end

Usage Examples

>> GovKit::OpenStates::State.find_by_abbreviation('CA')
>> GovKit::VoteSmart::Address.find(votesmart_candidate_id)
>> GovKit::OpenCongress::Bill.find(:number => 5479, :type => 'h', :congress => '111')

Objects returned from GovKit will have attributes for each field coming back from the API:

>> x = GovKit::OpenStates::State.find_by_abbreviation('CA')
=> #"Assemblymember", "lower_chamber_name"=>"Assembly", "upper_chamber_title"=>"Senator", "terms"=>[#> x.name
=> "California"

GovKit will raise GovKit::ResourceNotFound if a requested item isn't available.

Testing & Debugging

For debugging purposes, there's a raw_response reader provided for each object, which typically returns an HTTParty::Response object. To see the body of the HTTP response, you might look here:

(continuing the example from above)
>> x.raw_response.response.body
=> "{\n    \"lower_chamber_title\": \"Assemblymember\", \n    \"lower_chamber_name\": \"Assembly\", \n  ....

Bugs? Questions?

Please join the Govkit Google Group, especially if you'd like to talk about a new feature and get announcements.

Report a bug on our Lighthouse page.

Govkit's main repo is on Github: http://github.com/opengovernment/govkit, where your contributions, forks, and feedback are greatly welcomed.

Dear Canadians

For Canadian open government data, our friends up north have created a govkit-ca gem that lives in the GovKit::CA namespace and should interoperate just fine with this gem.

A GovKit for your country?

Let us know if you'd like to build a govkit for your region! We'd love to link to you. Your gem should be called, for example, govkit-uk (ISO 3166 country code), and your methods should live in the GovKit::GB namespace (for example).

Copyright (c) 2010 Participatory Politics Foundation, released under the MIT license

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言