ArticleslgStudy

computer science

HATEOAS

HATEOAS is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand HATEOAS rather than just read about it. In short: Hypermedia as the engine of application state (HATEOAS) is a constraint of the REST software architectural style that distinguishes it from other network architectural styles. With HATEOAS, a client interacts with a network application whose application servers provide information dynamically through hypermedia.

Key takeaways

  • HATEOAS belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect HATEOAS to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of HATEOAS from memory before moving on to harder problems.

Reference excerpt

Hypermedia as the engine of application state (HATEOAS) is a constraint of the REST software architectural style that distinguishes it from other network architectural styles. With HATEOAS, a client interacts with a network application whose application servers provide information dynamically through hypermedia. A REST client needs little to no prior knowledge about how to interact with an application or server beyond a generic understanding of hypermedia. By contrast, clients and servers in Common Object Request Broker Architecture (CORBA) interact through a fixed interface shared through documentation or an interface description language (IDL). The restrictions imposed by HATEOAS decouple client and server. This enables server functionality to evolve independently. The term was coined in 2000 by Roy Fielding in his doctoral dissertation.

Example A user-agent makes an HTTP request to a REST API through an entry point URL. All subsequent requests the user-agent may make are discovered inside the response to each request. The media types used for these representations, and the link relations they may contain, are part of the API. The client transitions through application states by selecting from the links within a representation or by manipulating the representation in other ways afforded by its media type. In this way, RESTful interaction is driven by hypermedia, rather than out-of-band information. For example, this GET request fetches an account resource, requesting details in a JSON representation:

The response is:

The response contains these possible follow-up links: POST a deposit, withdrawal, transfer, or close request (to close the account). As an example, later, after the account has been overdrawn, there is a different set of available links, because the account is overdrawn.

Now only one link is available: to deposit more money (by POSTing to deposits). In its current state, the other links are not available. Hence the term Engine of Application State. What actions are possible varies as the state of the resource varies. A client does not need to understand every media type and communication mechanism offered by the server. The ability to understand new media types may be acquired at run-time through "code-on-demand" provided to the client by the server.

Origins The HATEOAS constraint is an essential part of the "uniform interface" feature of REST, as defined in Roy Fielding's doctoral dissertation. Fielding has further described the concept on his blog. The purpose of some of the strictness of this and other REST constraints, Fielding explains, is "software design on the scale of decades: every detail is intended to promote software longevity and independent evolution. Many of the constraints are directly opposed to short-term efficiency. Unfortunately, people are fairly good at short-term design, and usually awful at long-term design".

Implementations

Hypertext HTML itself is hypermedia, with the <form>...</form> element in control of HTTP requests to links. Htmx introduces extensions to HTML to allow elements other than <form>...</form> and <a>...</a> to control requests.

JSON/XML HAL, hypermedia built on top of JSON or XML. Defines links, but not actions (HTTP requests). JSON-LD, standard for hyperlinks in JSON. Does not address actions. Hydra. Builds on top of JSON-LD to add definition of actions. Siren, hypermedia built on top of JSON. Defines links and actions. Collection+JSON, hypermedia built on top of JSON. Defines links and actions. JSON:API, defines links and actions.

See also htmx Hypertext Application Language Universal Description Discovery and Integration is the equivalent for the Web Services Description Language

References

Worked examples

Example 1 — a first encounter with HATEOAS

Start with the simplest possible case. Write down what HATEOAS claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to HATEOAS before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about HATEOAS ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of HATEOAS

In research
HATEOAS appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses HATEOAS in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
HATEOAS is common in secondary-school and first-year university syllabi. It links to neighbouring topics Distributed computing, Hypermedia, Web 2.0 neologisms, so understanding it makes those chapters shorter.
In everyday life
Look for HATEOAS outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “HATEOAS” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study HATEOAS in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what HATEOAS means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain HATEOAS out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is HATEOAS in simple terms?

Hypermedia as the engine of application state (HATEOAS) is a constraint of the REST software architectural style that distinguishes it from other network architectural styles. With HATEOAS, a client interacts with a network application whose application servers provide information dynamically throu…

Why does HATEOAS matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study HATEOAS?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on HATEOAS.

Tags

  • Distributed computing
  • Hypermedia
  • Web 2.0 neologisms

Keep exploring