About the VoterPunch API
REST Resource URIs
This data service follows REST principles. Each data set is associated with a different REST URI representing the resource. There are common facets that are always constructed the same as segment paths of the URI. Every URI is then constructed by concatenation of the correct facets in the correct order.
The following is a list of facets and how they are encoded:
- session
/{session}
(e.g. /110)- house
/h/{house}
(e.g. /h/senate)- year
/y/{year}
(e.g. /y/2007)- roll
/y/{roll}
(e.g. /r/215)- topic
/t/{id}
(e.g. /t/A5)
A resource always ends with a '/
' character.
For example, to construct "session 110, senate in year 2007, roll call 215", you
create the string: /110/h/senate/y/2007/r/215/
.
An API key is required to utilize our services. This key can be obtained by e-mailing 'admin@voterpunch.org'.
Any API request to the /services
hierarchy requires
basic authentication using your API key and passcode.
Vote Description Embedding by JavaScript
You can embed vote descriptions by including the script header:
<script type='text/javascript' src='http://voterpunch.org/embed/VoterPunch.js">//</script>
The you instantiate a voterpunch object:
var vp = new VoterPunch("mykey");
where 'mykey' is the voterpunch API key. The passcode is not required for this service.
Then to get a roll call vote description, just call the method getDescription
. For example, to
embed roll call [110:2007 house 382] and display it in a div
element with id 'desc':
vp.getDescription('desc',110,'house',2007,382);
Here is the result:
Note: The scrolling and box are provided by our stylesheet for this website. You'll need to apply your website's style to the embedded description.
Vote Description By Micro Format
Somewhere in your document, possible hidden from view, include an anchor element containing your key:
<a rel="voterpunch.key">your-key</a>
When you include the script, it will automatically create a voterpunch object with that key and
populate any descriptions you reference. This instance is available in the variable VoterPunch.instance
To reference a description, just link to it:
<div class="description"> <a rel="voterpunch.description" href="http://voterpunch.org/rollcall/110/h/house/y/2007/r/382/">Roll Call</a> </div>
The only important part is the anchor element (a) with the 'rel' and 'href' attribute. The script will replace the link with the description. The link should be contained in a parent element whose children are to be replaced by the description.
Roll Call Feed
Every roll call vote is available as separate feed. The feed URL is constructed by concatenating basic facets: session, house, year, and roll call number as follows:
http://voterpunch.org/services/rollcall/{session}/h/{house}/y/{year}/r/{roll}/
Topic Feeds
When a vote description is written, some number of topics are assocaited with the description. These topics use codes. To get the full description of the topics, and the topic hierarchy, you load a feed.
- Top-Level Topics
http://voterpunch.org/services/topic/
- Topic by Id
http://voterpunch.org/services/topic/t/{id}/
Each topic feed contains:
- An
atom:category
element containing the topic id. - An
atom:category
element containing the parent topic id. - An
atom:entry
element for each child topic.
Member Information
Member are represented by the govtrack.us
assigned identifier. If you need additional
information, you must lookup the full member profile. This resource exists at the URI:
http://voterpunch.org/services/member/{govtrack-id}/