LearnThatStack Ace your next interview
API Design · question
Question 23 of 110

What is HATEOAS and why is it important?

intermediate
← All API Design questions
Re-explain
Visual ↓

HATEOAS (Hypermedia as the Engine of Application State) means that API responses should include links to related actions or resources. This makes APIs self-discoverable and reduces client-server coupling.

Example response with HATEOAS:

{
  "id": 123,
  "name": "John Doe",
  "email": "john@example.com",
  "_links": {
    "self": "/users/123",
    "orders": "/users/123/orders",
    "edit": "/users/123",
    "delete": "/users/123"
  }
}

Benefits include improved API discoverability, reduced documentation needs, and easier API evolution.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for API Design One question at a time. Answer out loud, get graded, see what you missed.
Related concept

Thinking in resources: what REST actually is

REST is constraints, not JSON over HTTP: address resources, let methods decide the action, send hypermedia links to what's next and more.

For this question · chapter 3 of 3Watch the _links block become buttons that change when the order is paid, and see what breaks for the client that ignored it.

3/3 Links tell the client what it may do next
HATEOASLinks tell the client what it may do nextthe constraint most APIs skipClient A, keeps a URL mappaidCancelPayClient B, follows linkspaidnothing to drawno linksAPI serverno _links block200 paid, spec publishedOpenAPI spec: cancel, pay, refundHTTP API, level 2, by choice
HATEOASLinks tell the client what it may do nextClient A, keeps a URL mappaidCancelPayClient B, follows linkspaidnothing to drawno linksAPI serverno _links block200 paid, spec publishedspec: cancel, pay, refundHTTP API, level 2, by choice

Links tell the client what it may do next

  1. One constraint is still missing, and this is not commonly implemented in practice: the uniform interface also asks for links in the response. Two clients load the same order, status pending. Client A has a map of URLs and and got the Cancel and Pay buttons from that map. Client B relies on links in the response and has got nothing yet, as nothing in the response said what Client B may do.
  2. The server adds a _links block with cancel and pay, then sends the value to client B. Client B reads the links and got two things it can do next, Cancel and Pay. Sending the links with the value is HATEOAS, hypermedia as the engine of application state. The order's state decides which links appear, and those links decide what the client offers.
  3. The order is paid, so the response says paid and the links say refund. The new value reaches Client B. Client B stops getting Cancel and Pay and got Refund instead, with no code change. Client A still got Cancel and Pay, because its map from state to buttons does not know the order is now paid.
  4. Client A sends Cancel from its own map of URLs and gets a 409. Client B sends Refund from a link the server sent and gets a 200. B never built a URL and never offered an action the server had not offered first, so the server can move URLs and rules without breaking B.
  5. Client A keeps working without the links, but client B has nothing left to display. So why does almost nobody ship hypermedia? Most APIs stop at level 2 of the Richardson model: resources and methods, URLs in the docs and the SDK, no links in the body. Level 3 adds the links.
  6. A generated SDK fails the build when a URL moves. The build failure is the protection level 3 would have given at runtime. Most teams make that trade on purpose: an HTTP API at level 2. They instead use OpenAPI spec to publish their URL map.
Chapter 3 · step 1 of 6

One constraint is still missing, and this is not commonly implemented in practice: the uniform interface also asks for links in the response. Two clients load the same order, status pending. Client A has a map of URLs and and got the Cancel and Pay buttons from that map. Client B relies on links in the response and has got nothing yet, as nothing in the response said what Client B may do.

1 of 6 Use ← → or swipe See the concept: all 3 chapters in it

© LearnThatStack - diagrams may not be republished without permission.

How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

  • Why do so few real-world REST APIs implement HATEOAS? Name the costs: many clients hardcode URLs anyway, generic hypermedia clients are rare, and payloads and design work grow.
  • If clients shouldn't build URLs, how does a client know what each link means? The link relation name carries the meaning. Clients code against names like 'orders' or 'next', and formats like HAL fix where links live.
  • How would the links change as an order moves from placed to shipped? The server sends only the links valid right now, so 'cancel' drops out after shipping, and the client shows actions based on which links exist.
  • In your example, edit and delete share one URL. How does the client know which HTTP method to use? A plain link carries only a URL. The method comes from docs or from a richer format like Siren or HAL-FORMS that describes actions.
  • What are REST's other core constraints, and which one does HATEOAS belong to? It is part of the uniform interface. Fielding holds that an API without it isn't fully REST, and Richardson's model puts it at level 3.

What you can say

  1. HATEOAS means an API response includes links to related resources and the actions you can take next, so the client finds its way from the response itself.
  2. For example, fetching user 123 returns the name and email plus a _links block with self, orders, edit and delete.
  3. The client follows those links instead of building URLs itself, so it depends on link names rather than on the server's URL layout.
  4. That makes the API easier to discover, means clients lean less on documentation, and lets the server change URLs without breaking anyone who follows the links.
  5. The catch is that it only helps when clients really follow the links, and most teams hardcode URLs anyway, so full HATEOAS is rare outside things like pagination links.

Weak answers to avoid

  • Expands the acronym and stops Spelling out the name shows nothing. Say what goes in the response, give a link or two, and explain how following links lowers coupling.
  • Says links replace all documentation Links say where to go, not what fields mean or what a rel name implies. The claim is less documentation, not none.
  • Lists every link on every response The point is that links reflect current state and permissions. A delete link on a record the user can't delete tells the client something false.
  • Claims every REST API uses it Most real APIs skip it or add only pagination links. Say so, and name the cost, which is bigger payloads plus clients that hardcode URLs anyway.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the API Design cheatsheet.

← Back to all API Design questions
Pro · $10/mo

90 of 110 API Design answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime