OpenStates from R via API: watch your elected representatives10 Jun 2011 R Datasets
I am writing some functions to acquire data from the OpenStates project, via their API. They have a great support community at Google Groups as well.
On its face this post is not obviously about ecology or evolution, but well, our elected representatives do, so to speak, hold our environment in a noose, ready to let the Earth hang any day.
Code I am developing is over at Github.
Here is an example of its use in R, in this case using the Bill Search option (billsearch.R on my Github site), and in this case you do not provide your API key in the function call, but instead put it in your .Rprofile file, which is called when you open R. We are searching here for the term ‘agriculture’ in Texas (‘tx’), in the ‘upper’ chamber.
<div style="overflow: auto;"><div class="geshifilter"><pre class="r geshifilter-R" style="font-family: monospace;">> temp <- billsearch(‘agriculture’, state = ‘tx’, chamber = ‘upper’)
 “Congratulating John C. Padalino of El Paso for being appointed to the United States Department of Agriculture.”
 “2010-08-11 07:59:46”
 “2010-09-02 03:34:39”
 “SR 1042”</pre></div></div>Created by Pretty R at inside-R.org
Apparently, the first bill (SR 2042, see $bill_id at the bottom of the list output) that came up was to congratulate John Paladino for being appointed to the USDA.
The other function I have ready is getting basic metadata on a state, called statemetasearch.
I plan to develop more functions for all the possible API calls to the OpenStates project.