Chapter 11. HTTP for APIs
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.
The New HTTP/1.1 Specification
Throughout this book Iâve used âRFC 2616â as a shorthand for the HTTP 1.1 ...
Get RESTful Web APIs now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.