A Seven‑Step Methodology for Designing, Implementing, and Maintaining Web APIs
This article presents a comprehensive, seven‑step methodology for designing, implementing, and maintaining Web APIs—covering business use‑case definition, semantic description, state‑diagram modeling, naming harmonization, media‑type selection, semantic archive creation, coding, and publishing—while offering interviews and further reading recommendations.
Designing, implementing, and maintaining Web APIs is not merely a challenge; for many companies it is a mission‑critical task. This article leads readers through a journey from defining business use‑cases to a design methodology, solving implementation difficulties, and viewing long‑term maintenance of public Web APIs, with interviews of influential figures and a recommended reading list.
Excellent design goes beyond URLs, status codes, headers, and payloads
Typical Web API guidelines focus on generic functional features such as URL design, proper use of HTTP status codes, methods, headers, and payload design. While important, these details are implementation specifics rather than true API design. The way a service’s core functionality is expressed and described contributes significantly to the API’s success and usability.
A solid design process defines a repeatable set of steps that developers, designers, and architects can share to produce an accessible, useful Web API. A mature methodology can evolve over time without harming implementation details, allowing platform, OS, or framework changes to remain independent of the design.
API Design Seven‑Step Method
The following summarizes the seven‑step methodology described in Richardson and Amundsen’s "RESTful Web APIs". It is intended as a guide that teams can adapt to their own skills and goals.
Note: the list contains seven items, but five are pure design steps; the remaining two (implementation and publishing) provide an end‑to‑end experience.
Iterate through the steps as needed. For example, after drawing the state diagram (step 2) you may realize more work is required in step 1, or when you approach coding (step 6) you might discover missing elements from step 5.
Step 1: List All Components
Identify every data fragment that a client may request from or send to the service—called semantic descriptors. The perspective is client‑centric; designing the API for client consumption is crucial.
For a simple to‑do list app, semantic descriptors might include:
id – unique identifier for each record
title – title of the to‑do item
dateDue – due date for the item
complete – boolean flag indicating completion
A full‑featured application would add descriptors for categories, user information, etc., but the example keeps it simple.
Step 2: Draw the State Diagram
Create a diagram where each box represents a possible representation containing one or more semantic descriptors. Arrows indicate transitions triggered by protocol requests, noting whether they are safe (e.g., HTTP GET) or unsafe/non‑idempotent (e.g., HTTP POST) versus unsafe/idempotent (e.g., HTTP PUT).
In the to‑do example, client actions include reading the list, filtering the list, reading a single item, creating an item, and marking an item complete. The diagram helps uncover missing actions or data points, prompting a return to earlier steps.
Step 3: Harmonize "Magic" Strings
Replace internal descriptor names with well‑known public vocabularies such as Schema.org, microformats.org, Dublin Core, and IANA Link Relation Values. This improves API discoverability for developers who are already familiar with these terms.
Example mappings for the to‑do service:
id → Dublin Core identifier
title → Schema.org name
dueDate → Schema.org scheduledTime
complete → Schema.org status
read‑list → IANA collection
filter‑list → IANA search
read‑item → IANA item
create‑item → http://mamund.com/rels/create-item (RFC 5988)
mark‑complete → IANA edit
Step 4: Choose a Media Type
Select a media type that can convey both data descriptors (e.g., "identifier", "status") and action descriptors (e.g., "search", "edit"). Common hypermedia formats include HTML, HAL, Collection+JSON, Siren, JSON‑API, and UBER. The chosen format should also align with the target protocol (HTTP, WebSockets, XMPP, MQTT, CoAP).
In this example HTML is used as the message format with HTTP as the protocol. HTML provides list (
), and span ( ) elements for data, and anchor ( ) or form elements for actions.
Note: HTML lacks native support for PUT, so an additional field can be added to make POST behave idempotently.
Step 5: Create a Semantic Archive
A semantic archive documents all descriptors used in the design, serving as a guide rather than an implementation specification. Formats include ALPS and JSON‑LD + Hydra.
Service Descriptor Formats
WSDL
AtomSvc
WADL
Blueprint
Swagger
RAML
Archive Formats
Application‑Level Profile Semantics (ALPS)
JSON‑LD + Hydra
Step 6: Write Code
Provide the design documents (state diagram and semantic archive) to backend and frontend developers so they can implement the service, ensuring that each client request triggers the correct state transition and that responses use the selected media type with hypermedia controls.
Step 7: Publish Your API
Expose at least one stable URL (a "board URL") that always responds, publish the semantic archive, and optionally publish human‑readable documentation and tutorials to help other developers consume the API.
Conclusion
This article discussed a set of steps for designing Web APIs, emphasizing correct description of data and actions and recording them in a machine‑readable way so that developers can implement client and server sides without direct contact.
List all components – gather every data element the client needs.
Draw the state diagram – record all actions (state changes) the service provides.
Harmonize magic strings – align public interface names with known vocabularies.
Choose a media type – select a message format that best fits the target protocol.
Create a semantic archive – write a document defining all descriptors used.
Write code – share the archive with developers, implement, test, and adjust as needed.
Publish your API – expose a stable URL and the archive so others can build new services or clients.
During the design process you may discover missing elements, need to redo steps, or make trade‑offs; catching these early leads to a more robust API that can evolve with new formats and protocols.
Hope this article inspires you to create a repeatable, reliable API design methodology for your organization or team.
(Source: InfoQ)
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
