Building a Hypermedia API in CouchDB

php|architectThe latest issue of php|architect includes an article of mine on Building a Hypermedia API in CouchDB. The article’s description:

This article demonstrates how to create a hypermedia data API using CouchDB, a document database and application server that is accessed through an HTTP API. URIs identify CouchDB resources such as databases, documents, attachments, and configuration sections. HTTP methods define actions on these resources. Requests from CouchDB clients—and responses to CouchDB clients—are self-describing through the use of request headers, response status codes, and response headers. However, CouchDB’s core API does not include hypermedia controls. This article will demonstrate how you can add hypermedia controls to your CouchDB application through the use of show functions, list functions, document update handlers, rewrite rules, and a virtual host or a reverse proxy.

The article uses the JSON Hypermedia API Language (HAL) draft media type (application/hal+json). This allows for the creation of a generic hypermedia API. HTTPie is used to demonstrate interactions with the hypermedia API.

The article includes a companion proof of concept Hypermedia API built in CouchDB which is available on GitHub. PHP, the Doctrine CouchDB Document Object Mapper (ODM), and Cilex are used to push the proof of concept application to CouchDB. PHPUnit and Guzzle are used for a suite of tests that exercise the hypermedia API served directly from CouchDB.

This same issue of php|architect also includes the following articles:

  • Using SimpleDB by Eli White
  • Stored Procedures and Variables in MySQL by Chris Tankersley
  • Performance: Performance Concepts from Those That Know by Matthew Setter
  • Outside the Box: Method Overloading by Joshua Thijssen