🔌
API Styles
Contracts for system-to-system communication
REST
RESTful APIs, HTTP/JSON, OpenAPI/Swagger
The most common API style. Uses HTTP verbs (GET, POST, PUT, DELETE) on resource URLs. Stateless, cacheable, and human-readable. OpenAPI (Swagger) provides machine-readable API specifications.
🏛️ Context: REST is the safe default for most integrations. Enforce OpenAPI specs as contracts. Use API-first design — spec before code. Versioning strategy (URL path vs. header) should be decided once and applied consistently.
GraphQL
GraphQL, Apollo, Schema-first API
Query language for APIs where clients specify exactly what data they need. Single endpoint, strongly typed schema. Eliminates over-fetching (getting too much) and under-fetching (needing multiple calls).
🏛️ Context: Excellent for frontend-driven development with diverse client needs. Federation (Apollo Federation) enables composing a single graph from multiple team-owned subgraphs. Watch for N+1 query problems on the server side.
gRPC
gRPC, Protocol Buffers, Protobuf, HTTP/2
High-performance RPC framework using Protocol Buffers for binary serialisation over HTTP/2. Supports streaming (unary, server, client, bidirectional). Significantly faster than REST/JSON for service-to-service calls.
🏛️ Context: Preferred for internal microservice communication where performance matters. Not browser-native — use gRPC-Web or a REST gateway for external consumers. Proto files serve as strict contracts.
WebSocket
WebSocket, Socket.IO, SSE
Full-duplex persistent connection enabling real-time bidirectional communication. Used for chat, live dashboards, collaborative editing, and gaming. Server-Sent Events (SSE) is the simpler one-way alternative.
🏛️ Context: WebSockets break the request-response model — infrastructure (load balancers, firewalls) must support persistent connections. Consider SSE for one-way streaming; it's simpler and works with standard HTTP.
AsyncAPI
AsyncAPI, Event-driven API specs
A specification format (like OpenAPI but for async) that documents event-driven APIs — message brokers, channels, message schemas, and bindings. Enables machine-readable documentation of asynchronous integrations.
🏛️ Context: As organisations adopt event-driven architectures, AsyncAPI brings the same governance to events that OpenAPI brought to REST. Essential for discoverability in event-heavy ecosystems.