In October of 2012, Temboo released a special kind of DevShortcut: superpowerChoreos that take care of a host of development tasks and hook into multiple APIs. One of them was called GoodCitizen.Civic and it returned civic information from a specified area using data.gov, SunlightLabs, LittleSis, and GovTrack … in five lines of code.
The following is a page found from a developer’s logbook as he tried to build the very same app (minus one API):
I’ll start by trying to get demographic data from Data.gov. The overall Data.gov documentation is a sprawling mess. Finally I realize that the actual API I’m looking for isn’t listed under the Census or Demographics sections at all — it’s actually called the “broadband map API.” (And here I was thinking that broadband was about internet connections, rather than census counts. Whatever.)
There’s no API wrapper that I could find for the Data.gov “broadband map” API, so I’m just going to make the HTTP call directly myself. Awesome. In order to do that, I need an HTTP client library — the Apache HTTPClient lib has worked well for me in the past, so I’ll add that to the project.
Of course, since it’s an Apache library I actually need to add in 4 other libraries that are dependencies (httpmime, httpcore, commons-codec, and commons-logging).
To efficiently handle the data returned by Data.gov, I need to add another library — Apache IOUtils. (Yes, I could do my stream-to-string conversions, etc., without this, but it would make the code much longer.) Now that I’ve found my way to the right place, the Data.gov API documentation isn’t fantastic, but after spending a bit of quality time wrestling with the syntax I can make the call.
Now, on to Sunlight Labs.
The Sunlight Labs API docs page points me at a Java library on Github created 3 years ago by some guy named “lordjoe” (https://github.com/lordjoe/java-sunlightapi/)
The documentation refers to some JAR files that don’t actually exist in the git repo, but whatever; I’ll give it a try.
I cloned the repo and ran the test program; it fails with an error. Not exactly encouraging, but…
Upon further investigation, it turns out that lordjoe’s Sunlight Labs wrapper API I downloaded doesn’t actually include a method to get a list of legislators by coordinates. Fantastic. Fortunately, there’s another Sunlight Labs wrapper on Github written by “tdanforth” two years ago. This one isn’t referenced by their documentation, but I’ll give it a try.
Again, this library is in source format — there’s no JAR available — but at this point I don’t really care. (tdanford has actually included an ANT buildfile, but it’s not worth trying to reconfigure now. I’ll just add this as an item on my todo-list, if I actually get this library functioning.)
The API wrapper provided by tdanford does include a method to list legislators by coordinates (hooray!) but it turns out the way the library is structured doesn’t actually let me use the method because the Legislators API object is defined as a private inner class (@#$%#@!) — so it looks like I’m going to need to refractor tdanford’s API wrapper to make it work in my project.
Refactor completed. Next, I want to use the Sunlight Labs API data to make a request to GovTrack to get information about what each legislator has voted for. As far as I can tell, the only API wrapper available for GovTrack is in Ruby — so again, I’m going to need to write my own wrapper. Fortunately, the GovTrack API documentation is really clean and well presented, so hopefully it won’t hurt too much.
The last step in my project is connecting to Capitol Words, to retrieve top phrases for each of the legislators. There doesn’t seem to be any wrapper library at all for the CapitolWords API, so I’m back to assembling my own HTTP requests. (Deep breath.)
Lines of code (without doing any parsing on the API data): 234
External library dependencies: 9