REST is dead; long live REST

It is the boundless effort of the world: to become realized in its totality, that is, to evade rest.
— Edouard Glissant

Let’s imagine there are no hard drives, only random-access memory. Would REST still be a thing? Our address bars would effectively become sites for massively interpretative activity. Would we still have “vanity URLs”? Most probably. But there’d be some URLs out there that would be massive, for they would be doing the same work “storage” once did. RAM would probably be orders of magnitude bigger on average. Our lives would entirely depend on ensuring certain URLs live: living URLs, not just living standards. Wild!

Maybe this idea is silly. Maybe it’s not. But one thing stands out: your last “how to build a REST API in technology X” did not at all cover REST. Let’s remind ourselves what REST means: affordances.

  1. Controls in the payload because metadata = data
  2. Appropriate status codes (201 for POST, 202/204 for DELETE, etc)
  3. No message to interpret beyond the status code for modifying verbs (see 2)
  4. As many controls are in the payload, they should be expressible in the URL (page=N parameter corresponds to next/prev; filter/sort/order/pagination should be both in the controls and expressible in the URL; what other modes of HTML5 semantics can we canonicalize in the URL with respect to their link relations/controls?)
  5. Actions in the URLs: /api/v1/entity/:entityId/actionName/invoke

All this so you can build web interfaces from semantic web. All this so you can build your user interface from your web interface from semantic web. Your “frontend development” becomes massively easier when you think from the perspective of data having its own agency, its own “affordance”. It’s not that backend or frontend is “easier” in which to develop, but that affordance-first development (controls on the data, metadata = data) simplifies the problem of user interface development and state management tremendously. And you enable developers working with the data to discover new modes and kinds of affordances as they work with it. This is killing not just two birds with one stone: it’s wiping out a flock of birds.

As timbl has stressed, apart from the server address, URLs should be treated as opaque; it’s the “rel” value that matters.

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 automation) obtains choices and selects actions.
— Roy Fielding

Without hypermedia as the engine of application state (HATEOAS, or just “hypermedia controls” or “hypermedia views”), you cannot call the API RESTful.

REST is not just enabling access to data via HTTP Verbs. Stop misleading future developers or trying to garner clicks. You’re abusing semantic web.

#rest #hypermedia #hateoas #affordance #semanticweb

1.50 GEEK