Actual examples for HATEOAS (REST-architecture)

RestHateoas

Rest Problem Overview


as everyone may have noticed, there are lot of fake/rudimentary REST-APIs in the wild (which implement a HTTP-API and call it REST without following the hypertext-as-the-engine-of-application-state requirement, which led to the famous rant of Roy T. Fielding, the man who first specified the REST-paradigm).

I've been unable to find any practical examples of a truly hypertext driven REST-implementation along with the associated application-specific media-type definitions for the state transitions.

Are there any publicly accessible examples of such implementations?

Rest Solutions


Solution 1 - Rest

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.

Solution 2 - Rest

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.

Solution 3 - Rest

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

Solution 4 - Rest

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.

Solution 5 - Rest

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpmfView Question on Stackoverflow
Solution 1 - ResttrendelsView Answer on Stackoverflow
Solution 2 - RestRich ApodacaView Answer on Stackoverflow
Solution 3 - RestWill SargentView Answer on Stackoverflow
Solution 4 - RestHedgehogView Answer on Stackoverflow
Solution 5 - RestjeremyhView Answer on Stackoverflow