Resource-Based APIs Exchange Messages
Resource-based APIs create a conversation between the business and a user or remote system. For example, suppose a user of a project management application was conversing with the API server. The conversation may look something like what’s shown in Figure 1.3.
Figure 1.3 An example interaction between an API client and API server, as if the user was talking to the server in conversational terms.
Does it seem strange to think about APIs as a chat session? It isn’t far off from what Alan Kay originally intended when he coined the term object-oriented programming. Rather than a focus on inheritance and polymorphic design, he envisioned object-oriented programming as sending messages between components:
I’m sorry that I long ago coined the term “objects” for this topic because it gets many people to focus on the lesser idea.
The big idea is “messaging.”3
Like Kay’s original vision for object-oriented programming, Web APIs are message based. They send request messages to a server and receive a response message as a result. Most Web APIs perform this message exchange synchronously by sending a request and waiting for the response.
API design considers the conversational message exchange between systems to produce desired outcomes by customers, partners, and the workforce. A great API design also considers how this communication evolves as requirements change.