Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actual examples for HATEOAS (REST-architecture) [closed]

Tags:

rest

api

hateoas

Its not an implementation in the sense of running code, but I really like the article "How to GET a cup of coffee" on InfoQ. It describes the process of ordering a coffee at Starbucks as a RESTful protocol. This goes beyond the typical "everything is a resource" REST introductory article and focuses on HATEOAS. Highly recommended.


How about the Sun Cloud API? From the introduction:

The API presupposes no particular structure in the URI space. The starting point is a URI, supplied by the cloud service provider, which identifies the cloud itself. The cloud's representation contains URIs for the other resources in the cloud, and also for operations which may be performed upon them (for example deploying and starting virtual machines).

The backstory might also be helpful.


Netflix has a REST API based on HATEOAS that includes links as part of the resources.


Isn't the RESTfulness of Sun Cloud API actually addressed in Roy's 4th point:

A REST API must not define fixed resource names or hierarchies (an obvious coupling of client and server). Servers must have the freedom to control their own namespace. Instead, allow servers to instruct clients on how to construct appropriate URIs, such as is done in HTML forms and URI templates, by defining those instructions within media types and link relations. [Failure here implies that clients are assuming a resource structure due to out-of band information, such as a domain-specific standard, which is the data-oriented equivalent to RPC's functional coupling].

Example 1 Fixed resource names in a defined heirachy:

From the Sun Cloud API: "... the representation of a VDC will include representations of the Clusters which inhabit it, which in turn include representations of the VMs within each cluster."

Example 2 out-of-band information, such as a domain-specific standard:

You have to have the wiki-page contents (out-of-band information) to know that the "resource communication mechanism" for the Cloud resource field "uri" is GET.


I realized this was asked a while ago, but I took a stab at demonstrating a "proper" REST API flow for a simple example. I tried to follow Roy's rules for REST - perhaps it could help: API Example using REST