skip to content

Hypermedia Controls and Link Relations

The mechanics of hypermedia: links and actions embedded in responses, standard and custom link relations, and URI templates that let clients navigate without hardcoding URLs. Interviewers ask to test whether you know what HATEOAS concretely looks like beyond the acronym.

part ofAPI stylesoverview, primer and where to startread it →
on this pageshow

questions

3

An order resource returns a cancel link while the order is pending, and stops returning it once the order has shipped. What is the client supposed to gain from that, and what does the client still have to know on its own?

level: middleimportance: should knowfreq 42%

basics

~20 s

The response advertises the transitions currently available, so the server owns the state machine and the client renders whatever affordances it is given instead of reimplementing the rules. The client still needs to understand each relation's meaning and what payload it takes, and the server still enforces every rule itself.

open as a page

When would an API return a parameterised link such as /orders{?status,page} marked templated instead of a fully resolved URL, and what does RFC 6570 expansion require the client to do with it?

level: seniorimportance: nice to knowfreq 26%

basics

~20 s

Use a template when the target is a family of URLs the server cannot enumerate - search, filter, lookup by an id the client holds. The client must expand it with an RFC 6570 implementation, supplying named variables; expansion handles encoding and drops undefined variables, and only then is the result a usable URL.

open as a page