80

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?

Lee Chee Kiam
  • 9,693
  • 10
  • 56
  • 76

1 Answers1

106

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.

astreltsov
  • 1,724
  • 1
  • 14
  • 20
  • 6
    Besides HAL, what are standards you are aware of? – Lee Chee Kiam Sep 14 '14 at 08:04
  • 16
    There's [collection+json](http://amundsen.com/media-types/collection/examples/) and at least a [couple](http://www.markus-lanthaler.com/hydra/) of [others](https://github.com/kevinswiber/siren) – astreltsov Sep 14 '14 at 12:38
  • 3
    There is also [collection+JSON](https://github.com/collection-json/spec), [JSON-LD](https://www.w3.org/TR/json-ld/), and the use of [link headers](https://www.w3.org/wiki/LinkHeader). – RAM Nov 06 '18 at 14:29