Think of the World Wide Web (and of any other RESTful API) as a technology stack. URLs are on the bottom; they identify resources. The HTTP protocol sits on top of those resources, providing read access to their representations and write access to the underlying resource state. Hypermedia sits on top of HTTP, describing the protocol semantics of one particular website or API.
The bottom layer answers the question “Where is the resource?” The middle layer answers the question “How do I communicate with the resource?” The top layer answers the question “What next?”
So far, this book has focused on the top layer of the stack—“What next?” That’s because the top layer is the tricky one. Most of today’s APIs use URLs and HTTP correctly, but don’t even bother with hypermedia.
In this chapter, I take a break from hypermedia, and go down a level to explain the advanced protocol semantics of HTTP. I don’t want to explain the HTTP protocol in detail; for that, I recommend HTTP: The Definitive Guide, by David Gourley and Brian Totty (O’Reilly). I’ll focus on features of HTTP that are especially useful in APIs, and features that new API developers may not be aware of.
Throughout this book I’ve used “RFC 2616” as a shorthand for the HTTP 1.1 specification. But Roy Fielding (of Fielding ...