HATEOAS

Also known as: Hypermedia as the engine of application state

On this page 8

HATEOAS, short for hypermedia as the engine of application state, is the REST architectural constraint under which a server tells the client what it can do next by embedding links and actions inside each response, instead of relying on URL patterns hard-coded in the client. In the field of APIs, it is the property that separates a fully RESTful interface from one that merely uses HTTP verbs and JSON.

The idea comes from the uniform interface constraint described in Roy Fielding’s 2000 dissertation, which defined REST. A client that follows HATEOAS needs to know only an entry point URL and the meaning of the link relations it encounters; everything else is discovered at runtime, much as a person browses a website by clicking links rather than typing addresses.

How hypermedia drives application state

HATEOAS works by making every representation a state description plus a set of transitions. When a client retrieves an order, the response contains the order data and links such as cancel, pay or track, and only the transitions that are valid in the current state appear. A shipped order, for example, no longer offers a cancel link.

Each link carries a link relation type (the rel value) that names its meaning, and a target URI. Standard relations such as self, next, prev, item and collection are registered by IANA under RFC 8288 (Web Linking); custom relations are usually expressed as URIs so that they stay unambiguous. The client is coded against relation names, not URLs, which is the source of the decoupling.

The following table breaks a hypermedia response into its working parts and states what each part contributes.

ComponentRoleExample
Resource stateCurrent data of the resourceOrder total, status, items
Link relationNames the meaning of a transitionrel: "payment"
Target URIWhere the transition is sent/orders/812/payment
Method or affordanceHow to invoke the transitionPOST with a form template
Media typeDefines how links are encodedapplication/hal+json
Components of a hypermedia response

Hypermedia formats used for HATEOAS

Plain JSON has no native concept of a link, so HATEOAS in practice depends on a hypermedia-aware media type that defines where links live and what they mean. HTML is the oldest and most complete example, because forms and anchors already express both navigation and actions.

Several JSON formats emerged to fill this gap, and they differ mainly in whether they describe only links or also actions with their required fields. The comparison below covers the formats most often seen in production APIs.

FormatLinksActions and formsTypical use
HALYes, in _linksNo, links onlySimple navigable APIs
JSON:APIYes, in links objectsLimited, by conventionResource-oriented CRUD APIs
SirenYes, in linksYes, in actions with fieldsWorkflow-heavy APIs
Collection+JSONYesYes, via templatesList and query APIs
JSON-LD with HydraYes, semanticYes, operation descriptionsLinked data and semantic web
HTMLYes, anchorsYes, formsBrowser-facing applications
Common hypermedia formats compared

Choosing a format is a long-term contract decision, because clients must parse it everywhere. HAL is the most widely adopted for its simplicity, while Siren suits processes in which the client must know which fields an action requires.

HATEOAS within the REST maturity model

HATEOAS is the top level of the Richardson Maturity Model, a popular way to grade how far an HTTP API follows REST. Most public interfaces described as a REST API stop at level two, using resources and HTTP methods correctly but documenting URL templates for clients to build.

LevelCharacteristicClient knowledge required
Level 0Single endpoint, RPC over HTTPAll operations and payloads
Level 1Distinct resources with URIsEvery URI pattern
Level 2HTTP methods and status codes used properlyURI patterns and method semantics
Level 3Hypermedia controls in responsesEntry point and link relations only
Richardson maturity levels

Fielding himself has stated that an API which is not driven by hypertext is not RESTful, a point frequently ignored in industry usage. The gap explains why the term REST is often used loosely for any JSON-over-HTTP interface.

How HATEOAS compares with other API styles

HATEOAS shifts workflow knowledge from client to server, whereas most competing styles keep it in the client or in a shared schema. GraphQL, gRPC and JSON-RPC rely on out-of-band contracts such as schemas or protocol buffer definitions, and an OpenAPI document plays a similar role for level-two REST.

StyleDiscovery mechanismCoupling to server URLsWorkflow logic location
HATEOAS RESTLinks in each responseLowServer
Level 2 REST with OpenAPIStatic description fileHighClient
GraphQLIntrospected schemaSingle endpointClient queries
gRPCProtocol buffer definitionsGenerated stubsClient
Where API styles store workflow knowledge

The styles are not mutually exclusive. An OpenAPI description can document link relations alongside a hypermedia API, and many teams publish both so that human developers and generated SDK code have a reference.

When HATEOAS pays off and when it does not

HATEOAS delivers the most value when business rules change often and many independent clients must follow them. Because the server decides which links to emit, a new rule such as “orders above a threshold need approval” can be enforced by withholding a link, without redeploying every mobile or partner client.

  • Long-lived public APIs benefit because servers can reorganize URLs without breaking clients, which eases API versioning.
  • Multi-step workflows such as checkout, onboarding or claims processing map naturally to state transitions.
  • Generic clients, such as API browsers and admin consoles, can render any resource by following links.
  • Pagination becomes simpler, because next and prev links remove client-side offset arithmetic.

The benefits shrink for internal APIs with one tightly coupled frontend, where the team owns both sides and can change them together. In such cases the added payload and design effort may not be justified.

Limitations and common mistakes

The main criticism of HATEOAS is that clients still need semantic knowledge: a link relation named approve is useless unless the client developer knows what approval means. Hypermedia removes URL coupling, but it does not remove domain coupling, and fully autonomous machine clients remain rare.

MistakeConsequenceBetter practice
Links without relation typesClients guess meaning from URLsUse registered or URI-based rel values
Static links in every stateNo state information conveyedEmit only valid transitions
Clients building URLs anywayDecoupling benefit lostFollow links from the entry point
Ad hoc link formatsEvery client needs custom parsingAdopt HAL, Siren or JSON:API
Undocumented relationsDevelopers cannot interpret actionsPublish a relation catalog
Frequent implementation mistakes

Other practical costs include larger response payloads, additional caching considerations for link-heavy representations and a steeper learning curve for client developers used to calling fixed endpoints.

The idea in brief

HATEOAS means that an API answer tells you what you can do next. Instead of a client memorizing every address, each response includes a short menu of links, and the menu changes depending on the situation.

Think of a well-designed website. You do not type the address of the checkout page; you click the button that appears once your cart has items. HATEOAS gives programs the same experience. The key takeaway is that the server guides the client, so the server can change its rules without forcing every app to be rewritten.

A practical scenario

A regional bank exposes a loan application API used by its own mobile app, a broker portal and two partner platforms. Each response for an application includes links such as submit, upload-document, withdraw and, for underwriters, approve. A draft application returns submit and upload-document; once submitted, only withdraw and status remain.

When regulators require an extra identity check for loans above 50,000 dollars, the bank changes server logic so that large applications receive a verify-identity link and no submit link until verification is complete. The partner platforms, which already render whatever actions the API offers, enforce the new rule without a single client release, and the bank avoids a coordinated rollout across four teams.