Choosing an API style is mainly about how client and server exchange data and what the interface is meant for. The five common approaches differ in data format, flexibility, and communication pattern.

ParadigmFormat / TransportCommunicationTypical use
RESTJSON over HTTPRequest/response, well cacheableBroad, public web APIs
GraphQLJSON, a flexible query over HTTPRequest/response, exactly the fieldsFlexible, nested data for frontends
gRPCProtocol Buffers (binary), HTTP/2RPC, fast and strongly typedInternal microservices in the backend
SOAPXML with fixed contractsRequest/response, strictly standardizedFormal enterprise integrations
WebSocketsArbitrary, persistent connectionBidirectional, real-time (push)Chats, live updates, dashboards

More depth per style: REST, GraphQL, gRPC and Real-Time & Events.

In practice these styles aren't mutually exclusive: REST and GraphQL can share the same data store, gRPC dominates internally between services, and WebSockets add a real-time channel on top of request-response APIs.

GraphQL query
GraphQL request: exactly the desired fields
{
  user(id: "42") {
    name
    email
    posts(last: 2) { title }
  }
}

GraphQL: a single request returns exactly the requested fields, here name, email, and a user's last two posts.

Sources

Keep reading