Course contentsShow
← Web Development
Lesson 1477 of 2,98227. REST API Design for FrontendFree lesson

HATEOAS: Hypermedia as the Engine of Application State

Understanding how APIs can include links to related resources and available actions.

HATEOAS: Hypermedia as the Engine of Application State

What you'll learn: How REST APIs can guide clients through available actions by embedding hyperlinks, making your API self-discoverable and reducing client-server coupling.

What Is HATEOAS?

HATEOAS (pronounced "hate-oh-ass") is the final constraint of REST architecture. It means your API responses don't just return data—they also include links to related resources and available actions. The server tells the client "here's what you can do next" directly in each response.

Think of it like a website: when you're on a product page, you don't need to memorize URLs for the cart, checkout, or related products. The page provides clickable links. HATEOAS applies this same principle to APIs.

How It Works

Instead of clients hard-coding all possible endpoint URLs, the server includes hypermedia links in its responses. These links tell the client what actions are currently available based on the resource's state.

Without HATEOAS (traditional approach):

{
  "id": 123,
  "title": "Learn REST",
  "status": "published"
}

With HATEOAS:

{
  "id": 123,
  "title": "Learn REST",
  "status": "published",
  "links": [
    { "rel": "self", "href": "/api/posts/123" },
    { "rel": "author", "href": "/api/users/45" },
    { "rel": "edit", "href": "/api/posts/123/edit" },
    { "rel": "delete", "href": "/api/posts/123" }
  ]
}

The client follows these links rather than constructing URLs itself. If the post were unpublished, the server might omit the "delete" link, guiding the client about what's permitted.

Why It Matters for Frontend Development

HATEOAS makes your frontend more resilient to API changes. URLs can change server-side without breaking clients—as long as the rel (relationship) names stay consistent, clients can discover the new paths automatically.

Key Takeaway: HATEOAS transforms your API responses into self-documenting guides that include links to related resources and available actions, reducing the need for clients to hard-code endpoint URLs and making your API more discoverable and evolvable.