Building APIs for Government Agencies with Drupal
Since President Obama took office in 2009, the United States government has been releasing data and building APIs as part of the Open Government Initiative. On May 9, 2013, the President signed Executive Order 13642, Making Open and Machine Readable the New Default for Government Information, mandating that "the default state of new and modernized Government information resources shall be open and machine readable." The immediate implications for federal agencies are clear and actionable (and detailed in the "Open Gov" blog series), but agencies are left to their own devices when implementing mechanisms to provide access to data.
Fortunately, Drupal can do that!
Publishing Data with Drupal
Websites and applications built upon Drupal can leverage the Services module to make data available to the public. Out of the box, the Services module can be configured to expose users, nodes, and taxonomy vocabularies and terms, and supports several popular request and response formats.
For more granular control of exposing data, the Content API module can be installed and configured to define the content types and fields that will be presented to the public.
Internal applications can also be exposed as custom Services resources. For example, a resource can be defined which queries a database that Drupal doesn't directly interact with and as long as the returned value is an array, Services will return the values in the requested format.
To support API users, the Services Documentation module automatically generates documentation for Services resources and can be extended to support additional documentation such as example requests and responses.
Architecting APIs deserves the same time and effort that websites and applications are afforded. To be entirely honest, neither the Services or Content API modules deliver an API built with best-practices in mind, but that's okay! In true Drupal fashion, the Services module is extremely extensible and permits rewriting resources' paths.
API Platforms and Facades
API management platforms such as Apigee and 3scale offer features such as analytics, access controls, and authentication, and can also serve as API facade layers. An API facade presents disparate resources to the public as a unified application. The private address of legacy applications can be mapped to publicly-available addresses through an API management platform which can alleviate the pain of rebuilding applications.
The GSA has recently published api.data.gov, an API management platform built specifically for federal agencies in order to simplify the process of releasing and managing APIs under the Open Data Initiative. The platform provides the same services as commercial API management platforms at no cost to federal agencies and gives users a single point of access for a bevy of government data.
APIs with Drupal
Drupal is a proven platform for many types of websites and user-facing applications, but it can also be leveraged to provide APIs to the public. Combined with the API management platform provided by GSA, federal agencies intending to launch an API have the tools and resources available to do so rapidly.