Sunlight Labs API One Year Later


It has been about a year since we launched the new version of the Sunlight Labs API and seeing as just recently it recieved it’s 500th user and 3,000,000th api call, we thought it might be good to take a look at the changes over the last year. This chart should give some idea of what the growth has been like to get to this point:

chart of api calls by date


The number one request has been the addition of committee data to the API, earlier this year with a great amount of work from some of the Congresspedia/OpenCongress interns we added a committee namespace that allows lookups on all committees and subcommittees. We have also added a number of new fields for members of congress, including member RSS and twitter id.

The second most requested feature was “do something about districts.getDistrictFromLatLong“. This method, useful for looking up congressional districts based on location, has proved the second most popular method in the API. Unfortunately when first implemented two years ago as an experiment it involved code that would do the calculation directly from shapefiles which were loaded on every request. As a result the method suffered from being quite slow (requests would take several seconds, compared to the milliseconds of a normal API query). We have finally made the time to improve this method, the API now uses GeoDjango with PostGIS which make such a method incredibly simple and an order of magnitude faster.

Client Libraries

Shortly after launch I released python-sunlightapi, a simple library for interfacing with the API more naturally from Python. Luigi Montanez quickly followed up with the Ruby equivalent.

In addition, Josh Nichols has an alternate Ruby library named daywalker, Aaron Brazell has released a PHP client for the Sunlight API, and Steve Lewis wrote a Java client at our OSCon Hackathon earlier this year.

edit: Just as this post was being published Michael Stephens linked me to his factor-sunlightapi. If Factor is your thing it is worth checking out as yet another way to use the API.

Saying Goodbye to Old Features

Over the past year have added some experimental features that haven’t seen the use we had perhaps hoped.

chart of api calls by method

As the above chart shows, the lobbyist and wordlist API have seen practically no use. These portions of the API are being deprecated for future removal. Maintaining the lobbyist data is a time consuming process and given the lack of use we have decided to stop this process for now: if you want the data we continue to provide our Lobbyist API Data Dump.

You will also notice that as of today we have removed the ‘sunlight_old_id’ that was a remnant of our first API and which we strongly discouraged people from using for the past year. Nobody has been assigned such an ID since the 109th Congress, so if your application was relying on them it you would have found it wasn’t working anymore. We recommend using the bioguide ID, which has emerged as a bit of a standard among similar APIs.

The Future of the API

Having fulfilled the two main requests we’ve gotten for the API, what we add next is uncertain. It is likely that the new GeoDjango backend will make us reconsider some of the geographic features that we had previously set aside. It is likely that we’ll start exposing some more local data including state level legislative districts and perhaps some basic mapping functionality. It is clear that the community was not clamoring for the lobbyist data, but perhaps there are other data sets we can provide via the API.

Another direction we are heading is towards more public maintenance of the core legislator data. The data has been made available via a github repository that users can submit changes to that will be reflected in the API once accepted. Speaking of this, our own Eric Mill just updated the twitter ids we had in the API, more than doubling the number of legislators we have twitter accounts for. We are looking at other ways to make it even easier for individuals to submit corrections to the data as they occur.

You can keep up to date with all future changes by following sunlightlabsapi on twitter or participate in the discussion at the Sunlight Labs API Google Group.