The main web API architectural styles are REST, RPC families (including JSON-RPC and XML-RPC), GraphQL, SOAP, WebSocket and event-driven APIs, gRPC (usually for internal or service-to-service communication), and webhook/callback patterns, each making different trade-offs in coupling, caching, efficiency, and tooling. Choosing among them is less about a single "best" style than about matching the interface's consumers, data shape, latency needs, and how much uniformity versus flexibility you want.
Why "Web API Architecture" Is Broader Than "REST vs. GraphQL"
The phrase in the question covers two related but distinct layers, and conflating them causes much of the confusion.
Architectural style is the interaction model: how clients and servers exchange data, what the unit of exchange is, and what constraints apply. REST and event-driven messaging are styles in this sense. Protocol and format are the transport and encoding: HTTP, WebSocket, TCP; JSON, XML, Protocol Buffers. A style can ride on more than one protocol.
A single system often mixes several styles: a public REST façade over internal gRPC services, plus webhooks for notifications, plus a GraphQL layer for a mobile app. So "which architecture" is usually a per-interface decision, not a per-company one.
One ambiguity worth naming early: the question does not specify the audience (public third parties vs. internal services), the data shape (resource-oriented vs. graph-like vs. command-oriented), or the transport constraints. Those unknowns change the recommendation, so the sections below explain where each style holds and where it stops applying rather than declaring a winner.
REST: Resource-Oriented and Cache-Friendly
Representational State Transfer (REST) is an architectural style described by Roy Fielding in his 2000 doctoral dissertation. It is not a protocol or a standard, which is why "RESTful" is applied loosely in practice. Fielding's constraints include client–server separation, statelessness, cacheability, a uniform interface, a layered system, and (optionally) code-on-demand.
In everyday web use, REST usually means: nouns as URLs (/orders/123), HTTP verbs as actions (GET, POST, PUT, PATCH, DELETE), status codes as outcomes (200, 201, 404, 409), and representations in JSON or XML.
Strengths: Cacheability. GET responses can be cached by browsers, CDNs, and proxies when headers permit. This is REST's biggest structural advantage and the reason it dominates public read-heavy APIs. Uniformity and familiarity. Tooling, documentation conventions, and developer intuition are mature. Statelessness simplifies horizontal scaling: any server can handle any request.
Limits and common confusion:
"REST" is often used to mean "HTTP + JSON," which is not the same thing. An API with /getUser?id=42 and action verbs in URLs is HTTP-based but not really RESTful in Fielding's sense. Over-fetching and under-fetching. A mobile client needing a customer plus three related resources may make several round trips or receive fields it discards. Chatty workflows with many small resources can be inefficient versus a single command endpoint.
REST suits CRUD-heavy domains, public APIs, and anything that benefits from HTTP caching and broad client compatibility.
RPC-Style APIs: JSON-RPC and XML-RPC
Remote Procedure Call (RPC) APIs model the interface as named operations rather than resources. The client calls createInvoice(...) rather than POST /invoices.
XML-RPC (late 1990s) encoded calls and responses in XML over HTTP. It is largely legacy but still appears in older integrations. JSON-RPC is a lightweight specification (versions 1.0 and 2.0) using JSON. A 2.0 request carries jsonrpc, method, params, and id:
Strengths: simple mental model, easy to map to internal functions, good for command-style operations and batch calls (JSON-RPC 2.0 supports batch arrays).
Limits: less naturally cacheable than resource GETs; HTTP status codes are often all 200 with errors inside the body, which can confuse monitoring and intermediaries; and the style encourages tight coupling to server-side method names.
This is a good example of register and use-case distinction: RPC is not "worse REST" — it is a different abstraction that fits action-oriented APIs (payments, device control, administrative commands) better than resource modeling does.
GraphQL: Client-Specified Data Shape
GraphQL, open-sourced by Facebook in 2015, lets clients request exactly the fields they need through a typed schema and a single endpoint, typically POST /graphql.
Strengths: Solves over-fetching and under-fetching for clients with varying data needs, especially mobile. Strong typing and introspection enable good tooling and schema documentation. Aggregation layer: it can front multiple backend services.
Limits and traps:
Caching is harder. Because requests are usually POST with query bodies, HTTP caching is not automatic; you rely on client-side normalized caches (e.g., Apollo-style) or persisted queries. Query complexity risk. A single deep query can be expensive; servers need depth limits, cost analysis, and timeouts. This is an operational obligation, not a free win. N+1 problems on the server if resolvers are naive; batching (e.g., DataLoader patterns) is common mitigation. "One endpoint" is not a security model. Authorization must be enforced per field/resolver, not just per route.
GraphQL fits products with many client types and evolving data needs; it is usually a poorer fit for simple public read APIs where HTTP caching already solves the problem, and for binary or file-transfer-heavy workloads.
SOAP: Contract-First and Standards-Heavy
SOAP (originally Simple Object Access Protocol) is a messaging protocol using XML envelopes, typically over HTTP but also over other transports. It is associated with WSDL contracts, WS-Security, and related WS-* standards.
Strengths: strong formal contracts, built-in extensibility for security and transactions, and deep roots in enterprise and regulated integrations.
Limits: verbose XML, heavier tooling, and a steeper learning curve. Many modern public APIs have moved to REST or GraphQL, but SOAP remains embedded in enterprise, banking, and legacy systems. Saying "SOAP is dead" overstates it; saying "SOAP is the default choice" understates the migration that has occurred.
gRPC and Protocol Buffers
gRPC is an RPC framework originated at Google, using HTTP/2 and Protocol Buffers by default. It supports unary calls plus streaming in both directions.
Strengths: compact binary encoding, efficient multiplexing over HTTP/2, generated client/server code from .proto schemas, and strong typing. It shines for service-to-service communication and low-latency internal APIs.
Limits: browser support traditionally required a proxy (gRPC-Web), though native browser support has been evolving; human-readable debugging is less direct than JSON; and public-facing consumption is less common than REST.
Common confusion: gRPC is an RPC style, so it shares RPC's action-oriented abstraction. Do not treat it as a REST variant.
WebSocket and Event-Driven Styles
WebSocket provides a persistent, full-duplex connection after an HTTP upgrade handshake. It suits real-time features: chat, live dashboards, collaborative editing, and streaming updates.
Event-driven architectures — including publish/subscribe, message queues, and server-sent events (SSE) — invert the request/response model: producers emit events, consumers react.
Distinctions worth keeping straight:
WebSocket vs. SSE: WebSocket is bidirectional; SSE is server-to-client only over HTTP and is simpler when you only need server push. Webhooks are outbound HTTP callbacks: instead of the client polling, the provider posts to a client-supplied URL on an event. They are simple but require retry, signature verification, and idempotency handling to be robust.
Event-driven APIs fit notifications, integrations, and high-throughput pipelines; they are a poor fit when the client needs an immediate, synchronous answer.
Comparison at a Glance
| Style | Unit of exchange | Typical transport/format | Best fit | Main cost |
|---|---|---|---|---|
| REST | Resource | HTTP / JSON, XML | Public CRUD, cacheable reads | Chatty workflows, over-fetching |
| JSON-RPC / XML-RPC | Method call | HTTP / JSON, XML | Command APIs, simple integrations | Weak HTTP semantics |
| GraphQL | Query over typed schema | HTTP / JSON | Varied clients, aggregation | Caching, query-cost control |
| SOAP | XML message | HTTP (and others) / XML | Enterprise contracts, WS-* | Verbosity, complexity |
| gRPC | RPC call, streaming | HTTP/2 / Protobuf | Internal service-to-service | Tooling, browser friction |
| WebSocket | Frames/messages | WS / varies | Real-time bidirectional | Connection management |
| Webhooks / events | Event | HTTP callback / broker | Notifications, integrations | Delivery guarantees, idempotency |
How to Choose Without Overgeneralizing
Match the style to constraints rather than fashion: Public, read-heavy, cacheable → REST is usually the low-risk default. Many client shapes with divergent field needs → GraphQL is worth the operational cost. Internal low-latency services → gRPC. Action-oriented commands → RPC (JSON-RPC or gRPC). Real-time or push → WebSocket, SSE, or webhooks depending on directionality. Enterprise contract-heavy integration → SOAP or gRPC depending on the ecosystem.
Two standing cautions: "RESTful" is frequently claimed without meeting REST's constraints, and "GraphQL fixes performance" is only true when queries are cost-controlled. Both are contextual claims, not universal rules, and the right answer depends on the audience, data shape, and caching needs the question leaves unspecified.