HATEOAS (Hypermedia as the Engine of Application State) and HAL (Hypertext Application Language) seem to be related but are not exactly the same. What is the relationship and difference between HATEOAS and HAL?
HAL is a simple format that gives a consistent and easy way to hyperlink between resources in your API. The HAL format is strictly coupled to HATEOAS. The main target of HATEOAS is to decouple the API Consumer from the paths used in the API.
HATEOAS, or Hypermedia as the Engine of Application State, is a complicated-sounding term for a simple idea: A client interacts with a REST API entirely through the responses provided dynamically by the server. Put even more simply: You shouldn't need any documentation or out-of-band information to use a REST API.
The Hypertext Application Language (abbr. HAL) is an open specification that provides a structure to represent RESTful resources. It defines two hypermedia types to extend for XML and JSON.
Hypermedia as the Engine of Application State (HATEOAS) is a constraint of the REST application architecture that distinguishes it from other network application architectures. With HATEOAS, a client interacts with a network application whose application servers provide information dynamically through hypermedia.
HATEOAS is a concept of application architecture. It defines the way in which application clients interact with the server, by navigating hypermedia links they find inside resource models returned by the server.
To implement HATEOAS you need some standard way of representing resources, that will contain hypermedia information (links to related resources), for example, something like this:
{ "links": { "self": { "href": "http://api.com/items" }, "item": [ { "href": "http://api.com/items/1" }, { "href": "http://api.com/items/2" } ] }, "data": [ { "itemName": "a" }, { "itemName": "b" } ] }
HAL is one of such standards. It is a specific format of resource presentation, that can be used to implement HATEOAS.
You can fully implement HATEOAS without following HAL at all if you prefer to follow another standard or use your own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With