Skip to content

Lesson 8 of 9 · 20m

HATEOAS Without the Religion

Where hypermedia controls genuinely help, how links and actions reduce client coupling, and when plain REST plus documentation is enough.

HATEOAS is the most argued-about and least practiced part of REST. The pure vision says clients should navigate an API like a website, discovering available actions from hypermedia. Real production practice is narrower: hypermedia is excellent for state transitions, pagination, and optional capabilities, but most clients still need documentation, schemas, and stable resource types.

{
  "id": "inv_9Zk2",
  "status": "open",
  "links": {
    "self": "/invoices/inv_9Zk2",
    "customer": "/customers/cus_41Hm",
    "pay": "/invoices/inv_9Zk2/payments",
    "void": "/invoices/inv_9Zk2/void-requests"
  }
}

The important part is not the link syntax; it is that pay and void appear only when valid for the object's current state. A client can render buttons from availability instead of duplicating your workflow rules. Once the invoice is void, those controls disappear or change.

That is the pragmatic win: the server remains the authority on state transitions.

{
  "data": [],
  "links": {
    "next": "/invoices?cursor=abc&limit=100",
    "prev": null
  }
}

Clients can implement paging without learning cursor composition. Do not make the link the only contract; still document parameters because integrators need to construct the first request, transform results, and test deterministically.

Action metadata is the bridge between hypermedia and forms

A link tells you where; it may not tell you what to send. Some APIs include action descriptors:

{
  "actions": {
    "pay": {
      "method": "POST",
      "href": "/invoices/inv_9Zk2/payments",
      "fields": {
        "amount": {"type": "integer", "required": false},
        "method": {"type": "string", "required": true}
      }
    }
  }
}

This can power generic admin tools, but it also becomes a parallel schema system. If your clients already use OpenAPI-generated SDKs, duplicating field schemas in every response may be cost without benefit.

Do not fake discoverability

True runtime discovery means a client can handle resources it has never seen. Almost no business client does that; mobile releases and compiled SDKs certainly do not. If the client must know what an invoice is anyway, hypermedia will not eliminate documentation. Use links as a coupling reducer and workflow signal, not as a substitute for contracts.

Standard shapes beat bespoke cleverness

If you adopt hypermedia, use a known convention such as HAL-style _links or a simple documented links object and stick to it. Consistency matters more than purity. Version the envelope if you change it.

Field notes

  • Absolute versus relative links both cause pain; be consistent and consider reverse proxies when generating them.
  • Do not expose links clients cannot invoke due to permissions unless you intentionally support capability discovery.
  • Hypermedia does not make breaking changes non-breaking; removing a link relation is still a contract change.
  • Start with pagination and state transitions. Those are the highest-value, lowest-mysticism uses.

Was this lesson helpful?

Sign in to rate