liveBook · Manning

Api type

As explained in The Design of Web APIs, Second Edition

An API type is a classification of an application programming interface based on its interaction model and technical conventions.

An API type classifies an interface by its interaction model and technical conventions. Choose it according to user needs, exposed capabilities, consumers, architecture, and operational context rather than defaulting to a familiar stack. section 1.6.2 section 14.8

REST is a common choice: identify business concepts such as User and Status, convert operations such as “Share a message” into POST /statuses, and model inputs and outputs such as a string-valued message. Identify capabilities before discussing HTTP so technical conventions do not obscure user needs or business processes. section 1.6.2 section 3.1.5

Match interaction requirements to API types:

  • Use SSE when consumers need streamed data. section 14.8.2
  • Use WebSockets when communication must be bidirectional. section 14.8.2
  • Consider event-driven architecture when sending events to internal systems. section 14.8.2
  • Consider GraphQL for a backend-for-frontend when its specific features provide value beyond a well-designed REST API over HTTP/2. section 14.8.2

Real-time product prices

If shopping partners must know about product price changes in real time, requiring them to reread every product each second is likely unsuitable. Streaming or event-oriented communication may better fit the requirement than a conventional REST polling design. section 14.0 section 14.8.2

Evaluate alternatives against user needs, efficiency, security, and design consistency. Also account for browser compatibility, internet communication, public or partner exposure, existing systems, and consumer limitations; different contexts can justify different API types. section 14.8.2 section 16.2.2

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains REST selection and compares alternatives by interaction requirement, but stops short of implementing each API type.
Examples
Uses POST /statuses, a library borrowing process, and real-time shopping price updates to expose design implications.
What it assumes
Recognizes business capabilities and concepts before applying HTTP, REST, or other technical conventions.
What you can do after
Evaluate and choose an API type by matching communication needs and constraints to REST or alternatives.
How it connects
Connects REST APIs with HTTP, SSE, WebSockets, event-driven architecture, GraphQL, gRPC, webhooks, and callbacks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.