Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relationship and difference between HAL and HATEOAS

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?

like image 542
Lee Chee Kiam Avatar asked Sep 13 '14 03:09

Lee Chee Kiam


People also ask

What is HAL in HATEOAS?

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.

What is HATEOAS concept?

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.

What is HAL in 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.

What is HATEOAS link?

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.


1 Answers

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.

like image 76
astreltsov Avatar answered Sep 20 '22 14:09

astreltsov