What does it mean that REST should be hypertext driven?

When I say hypertext, I mean the simultaneous presentation of information and controls such that the information becomes the affordance through which the user (or automaton) obtains choices and selects action. Roy T. Fielding - http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven

It is about one of the fundamental constraints of REST architectural style - Hypermedia As The Engine Of Application State (HATEOAS). It means that in any given moment, client, based on hypermedia in representation of current resource, must have all the information he needs to decide where to transit next(change its Application State). That hypermedia controls in hypertext connect resources to each other, and describe their capabilities in machine-readable ways. A REST client just needs to know one thing in order to communicate with REST server - understanding of hypermedia. Opposite, in a service-oriented architecture(SOA), clients and servers interact through a fixed interface shared through documentation or an interface description language (IDL).

HATEOAS decouples client and server so that they can be developed separately.

For example,

If you make an initial call to a rest service to add a customer using some URL /customers/ then you will get a response back (consider the customer is successfully added),

HTTP/1.1 201 Created
Location: http://www.myREST/customers/<uuid>/

Now the client who made the call to add customer knows how to find the corresponding customer from the link returned as a response header.

You may ask how does client know that he can make POST to /customer/. By different means - hypermedia controls, DSL specific formats and profiles.

Tags:

Rest