Introducing SODA 2.0: Not All APIs Are Created Equal
API Foundry creates a simple and powerful way to expose datasets as APIs. An important part of how that works is SODA 2.0, which defines the language that developers can use to access data. Previously, SODA was focused on exposing the Socrata view constructs and provided a good way to download datasets along with their metadata. With this release, we’ve extended SODA to include an API built with web and mobile applications in mind.
Inspirationally, SODA 2.0 comes from looking at combining SQL and REST. We wanted to provide an interface that was easy to access from a browser, CURL, or any modern programming language. Functionally, we wanted to create a language that would allow applications to sort, filter and aggregate data in the common ways needed for building end user applications.
We did a lot of work to make SODA 2.0 expressive. Let’s go through a quick spin of the API from a query point of view.
First, we can take a look at all the nominations by doing a simple GET request: https://sandbox.demo.socrata.com/resource/white-house-nominations-copy.json
Now, imagine what we really want is to find all the people nominated for the department of state. We can still allow very easy GET requests: https://sandbox.demo.socrata.com/resource/white-house-nominations-copy.json?
Notice, all we needed to do was to add “?agency_name=Department of State”, and we were able to filter the results by agency.
Cool, eh? But we’re not done yet. What, I actually want is to know how many nominees there are for each department.
I can add $select=agency_name,count(name)&$group=agency_name to the query string and now I get a count of all the nominees for each agency.
Pretty cool. However, what I REALLY wanted, was to find out how many nominees didn’t get an up or down vote, by their department. So, now I can refine my query further, and . . .
Really cool! I was able to add “$where=confirmation_vote ISNULL&$order=count_name desc” and before I know it, I can get the aggregation of all the nominees that did not have a confirmation_vote (at least at the time this dataset was created). Furthermore, I could sort it in descending order to make it easier for me to view the results.
And the coolest part: EVERY DATA SET IN SOCRATA CAN BE ACCESSED USING SODA 2.0
This means any data locked in spreadsheets, or hidden on hard drives scattered around you office can be uploaded to Socrata and made available through the simple and expressive SODA API. You can give access to any web or mobile applications, and they will have all the power of SODA 2.0 to build cool analyses, applications or visualizations.
Over the next few months, we hope to make SODA even richer and more expressive, but this is already a big step forward for Open Data APIs. To find out more about SODA 2.0, look at the getting-started documentation, which will cover the details of the full API including how to do updates and what libraries are available.