Chapter 9. The Design Procedure
Itâs taken quite a while, but Iâm now in a position to address the basic concern that may have led you to buy this book. You need to design an API: what should it look like? In this chapter, Iâll lay out a procedure that begins with business requirements and ends with some software and some human-readable documentation.
Two-Step Design Procedure
In its simplest form, the procedure has two steps:
- Choose a media type to use in your representations. This puts constraints on your protocol semantics (the behavior of your API under the HTTP protocol) and your application semantics (the real-world things your representations can refer to).
- Write a profile that covers everything else.
This wonât necessarily give you a good API. In fact, this version of
the procedure describes every API ever designed. If you wanted a
really generic design thatâs hard to learn, youâd blaze through step 1
by choosing application/json
as your representation format. Since
JSON puts no constraints on your protocol or application semantics,
youâd spend most of your time in step 2, defining a fiat standard and
describing it with human-readable API documentation.
Thatâs what most APIs do today, and thatâs what Iâm trying to stop. A big chunk of the work that goes into creating a fiat standard is unnecessary, and client code based on a fiat standard canât be reused. But doing anything else requires some preparatory thought and a willingness to reuse other peopleâs ...
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.