SOAP, REST, GraphQL and gRPC compared
Four ways to build an API, what each is good at, and how to choose without following fashion.
On the roadmap:Beginner · step 2: How the web works
Lesson 20 of 23 · 9 min read · quiz · exercise
The same job, four ways
An API lets one program ask another to do something. The main styles differ in format, contract and how the client asks for data.
| SOAP | REST | GraphQL | gRPC | |
|---|---|---|---|---|
| Format | XML envelopes | JSON (usually) over HTTP | JSON over HTTP, one endpoint | Binary Protocol Buffers over HTTP/2 |
| Contract | WSDL, very formal | OpenAPI (optional) | A typed schema | A .proto schema, required |
| Client asks by | Calling named operations | Resource URLs and HTTP verbs | Sending a query describing the fields wanted | Calling typed methods |
| Caching | Hard | Natural (HTTP caching) | Harder (usually one POST endpoint) | Not HTTP-cache friendly |
| Streaming | No | Limited (SSE, WebSockets separately) | Subscriptions | Built in (four modes) |
| Browser use | Possible, heavy | Native | Native | Needs a proxy (gRPC-Web) |
| Typical home | Banks, enterprise, older systems | Public and general-purpose APIs | Client-driven apps, mobile | Internal service-to-service |
SOAP
An older, XML-based protocol with a formal contract (WSDL) and a family of standards (WS-Security, transactions, reliable messaging). Verbose and tooling-heavy, but still common where strict contracts and built-in enterprise standards matter, such as banking, telecom and government. You will mostly meet it when integrating with existing systems.
REST
Design around resources identified by URLs (/orders/42), manipulated with standard HTTP verbs (GET, POST, PUT/PATCH, DELETE), and described with status codes. Strengths: simple, cacheable, works with every tool. Weaknesses: over-fetching (you get fields you do not need), under-fetching (several calls to assemble a screen), and no enforced schema unless you add one.
Figure SDA-CORE-20-1 · Three ways to call an API · © forcsguy.com
GraphQL
A single endpoint and a typed schema. The client sends a query naming exactly the fields it wants, even across related objects, and receives exactly that shape. It removes over- and under-fetching and suits varied clients (web, mobile). Costs: query cost control (a client can ask for something expensive), more complex caching, and server complexity (resolvers, the N+1 problem solved with batching).
gRPC (a form of RPC)
Remote procedure call: call a method on another service as if it were local. gRPC uses Protocol Buffers (compact binary, generated typed clients in many languages) over HTTP/2 with streaming. It is fast and has strong contracts, which is why it is popular between internal services. It is awkward to call straight from a browser and harder to debug by eye.
Choosing
- Who are the clients? Public developers and the broad ecosystem: REST. A few first-party apps with varied screens: GraphQL. Your own services: gRPC. A partner or legacy system: whatever they provide, often SOAP.
- How sensitive is performance and payload size? Internal high-volume calls favour gRPC.
- Do you need HTTP caching? REST makes it easy.
- Do you need streaming? gRPC, or WebSockets and server-sent events.
- Team skills and tooling: the best style is one your team can run well.
Many systems mix styles: REST publicly, gRPC internally, and GraphQL as a gateway layer over both.
Good habits in any style
- Version the API and avoid breaking changes.
- Use consistent errors and clear status codes.
- Paginate lists, and make unsafe operations idempotent with keys.
- Document with a machine-readable schema (OpenAPI, GraphQL SDL,
.proto). - Apply authentication, authorisation and rate limits at the edge (see the API security lesson).
Real-world reading
Related reading
- Backend Developer Roadmaproadmap.sh community · roadmap.shCourses
- Hello Interview: System Design in a HurryHello InterviewCourses
- Hello Interview: System Design WalkthroughsEvan King & Stefan Mai · Hello InterviewYouTube
- MDN: Cross-Origin Resource Sharing (CORS)MDN contributors · MozillaDocumentation
Show 6 moreShow fewer
- ByteByteGo: System Design Video SeriesAlex Xu · ByteByteGoYouTube
- RFC 9114: HTTP/3IETFDocumentation
- Learn GraphQLGraphQL Foundation · GraphQLDocumentation
- Scaling Your API with Rate LimitersPaul Tarjan · StripeBlogs
- Log Parsing with Logstash and Google Protocol Buffers at TrivagoTrivago engineers · TrivagoCase Studies
- Postman BlogPostman engineers · PostmanBlogs
Check your understanding
Question 1 of 3
0 correct so far
Which style lets the client ask for exactly the fields it needs in a single request?
Go deeper
- Microsoft REST API Guidelines and the GraphQL and gRPC documentation by Microsoft, GraphQL Foundation, gRPC authors: search for each; practical guidance on design, versioning and errors
Practise it: One server is not enough
Everything below is already set up for this lesson: change the design, run the traffic, and see whether you meet the goal.
- 1The task
- 2Build and test
Your URL shortener went live on a single server that runs the app and the database. A newsletter just linked to it and traffic jumped to 900 requests per second.
Goal: Serve the traffic with under 1% errors and a 95th percentile under 300 ms.
One app server handles about 400 requests per second. Adding servers only helps if something spreads requests across them.
Try it yourself
Choose an API style for each and justify it: (a) a public API for third-party developers, (b) a mobile app screen that combines data from six backends, (c) internal calls between two high-traffic services, (d) integration with a bank's legacy system.
Click what a strong design here would need:
More in Building blocks
© 2026 forcsguy.com. Original lesson text and diagrams. Books and sites linked above belong to their authors.