HATEOAS
What is HATEOAS?
HATEOAS stands for the phrase Hypermedia As The Engine Of Application State.
What problem does HATEOAS solve?
When we build an application with REST APIs unknowingly we tend to tightly couple frontend with backend.
Consider this case of fetching a user.
It is common to see the REST API responding with something like:
But, in the the client, we might see a button to see the users address. Clicking on this button would make the below API call.
Now, Why should the frontend know the address
URL?.
This is the tight coupling problem and what HATEOAS solves.
The idea behind HATEOAS
A REST API should return a complete document. This means the clients have all the data required to show the document and the actions associated with that document.
The solution - Hypertext Application Language (HAL)
HAL is a way to structure the the data the associated links in JSON or XML response. HAL specification by IETF is currently in a draft stage.
Example HALs