ArchitectureIntermediate

REST vs GraphQL vs gRPC: Choosing Your API Style

DeveloperHat Team
17 min read

TL;DR

REST, GraphQL, and gRPC solve the same problem three ways. Compare them on payload, streaming, caching, and tooling — and pick by caller and team, not fashion.

Every new service eventually faces the same question: how do clients talk to it? REST is the default most teams reach for, GraphQL is the answer when clients keep asking for different shapes of the same data, and gRPC is the answer when services talk to each other at volume. They are not three versions of the same idea. They are three different contracts — a resource URL, a client-shaped query, and a generated function call — and the right one depends on who calls the API, what the payload looks like, and how big the team is.

The three styles have settled histories, so the decision can rest on facts rather than fashion. REST comes from Roy Fielding's 2000 dissertation, Architectural Styles and the Design of Network-based Software Architectures, which defined the resource-oriented, stateless, cacheable style the web already ran on. GraphQL was created at Facebook in 2012, open-sourced in September 2015, and is now governed by the GraphQL Foundation; its specification reached the September 2025 edition — the first tagged edition since October 2021 — and it deliberately standardises only the query language, type system, and execution semantics, leaving transport and caching to implementations. gRPC was open-sourced by Google in 2015, runs on HTTP/2 with Protocol Buffers, and is under active development — gRPC Core 1.85 shipped in October–November 2026. The short version up front: pick REST when the API is public and cacheable, GraphQL when many different clients need different slices of the same data, and gRPC when your own services call each other. Everything below is the reasoning that makes those three sentences true.

Three ways to move data across the wire REST resources over HTTP GraphQL one endpoint, client query gRPC typed calls, binary wire GET /orders/42 one URL, one resource query { order { … } } client picks the fields GetOrder({ id: 42 }) generated stub call JSON · HTTP/1.1 cacheable, human-readable JSON · HTTP/2 single round trip Protobuf · HTTP/2 compact, streaming Same order, three contracts: a resource URL, a client-shaped query, a generated stub.

REST: the resource contract

REST models the world as resources with URLs, and uses HTTP itself as the interface: GET /orders/42 reads one, POST /orders creates one, PATCH /orders/42 changes part of one. The contract is the URL space plus the media type, and the server decides the shape of every response. That is both its strength and its limit — the shape is fixed, so clients get what the server sends, whether they need all of it or not.

# One resource, one round trip — but the server fixes the shape
curl https://api.example.com/orders/42 \
  -H "Authorization: Bearer <token>"

{
  "id": 42,
  "customer": { "id": 7, "name": "Asha", "tier": "gold" },
  "items": [
    { "sku": "KB-100", "qty": 2, "price": 49.99 },
    { "sku": "MS-220", "qty": 1, "price": 29.99 }
  ],
  "total": 129.97,
  "status": "shipped",
  "tracking": { "carrier": "UPS", "number": "1Z999AA10123456784" }
}

A mobile client that only wants the status and the tracking number still downloads the customer record, both line items, and the total. That is over-fetching, and the standard fix is more endpoints or query parameters (?fields=status,tracking) — which is, quietly, rebuilding a query language on top of REST. The opposite problem, under-fetching, is worse: a screen that needs an order, its customer, and its shipment makes three round trips unless the API offers an aggregate endpoint. REST's honest answer to both is that the server owns the shape, and clients adapt.

What REST gives you in exchange is the whole HTTP ecosystem, free. Responses are cacheable with Cache-Control and ETag — a CDN can serve GET /orders/42 without ever reaching your origin, and a browser can cache it the same way. Any HTTP client in any language works with no code generation and no schema tooling. Errors are HTTP status codes, which every load balancer, proxy, and monitoring tool already understands. And because the contract is just URLs and JSON, versioning is a visible, explicit decision: a new URL version, a new media type, or additive fields. The cost is discipline: nothing in REST stops a team from shipping fifty ad-hoc endpoints with inconsistent shapes, and the OpenAPI document that is supposed to describe them is a separate artifact that drifts from the code unless it is generated from it.

REST is for: public and partner APIs, anything a CDN should cache, teams that want the lowest possible tooling burden, and APIs whose consumers are unknown — because the contract is the web itself, and every client already speaks it.

GraphQL: the client-shaped query

GraphQL inverts the contract. Instead of the server fixing the response shape, the client sends a query describing exactly the fields it wants, and the server executes it against a typed schema. One endpoint, one request, no over-fetching and no under-fetching — the mobile screen asks for status and tracking, the admin screen asks for everything, and both hit the same endpoint.

# The client picks the fields — the server fills in exactly those
query OrderStatus($id: ID!) {
  order(id: $id) {
    status
    tracking {
      carrier
      number
    }
  }
}

# The schema is the contract: types, fields, and what each one costs
type Order {
  id: ID!
  status: OrderStatus!
  total: Float!
  customer: Customer!
  items: [OrderItem!]!
  tracking: Tracking
}

type Query {
  order(id: ID!): Order
}

The schema is GraphQL's real product. It is a typed, introspectable description of everything the API can do, which is why the tooling around it is so good: clients generate typed hooks from the schema, the playground documents itself, and a breaking change is a schema change you can detect in CI rather than a runtime surprise. Schema evolution is additive by design — add a field, deprecate an old one — so the API can grow without version numbers. That is also the reason GraphQL fits organisations with many clients: one schema serves the web app, the iOS app, and the internal dashboard, each taking the slice it needs.

The costs are real and they are all on the server side. A query is a program, and a program can be expensive: a deeply nested query (customer.orders.items.product.reviews...) can fan out into hundreds of database calls — the N+1 problem — unless resolvers batch and cache their loads, which is what the DataLoader pattern exists for. Caching is the second cost: because every request is a POST to one endpoint with a different body, HTTP caching mostly does not apply, so teams cache at the client (a normalised cache in Apollo Client or Relay) or adopt persisted queries so identical operations get stable ids a CDN can key on. And a single GraphQL endpoint is a single point of failure for every client, so its availability, rate limiting, and query-complexity limits have to be engineered, not assumed. Federation — composing one graph from many teams' subgraphs, as in Apollo Federation — solves the organisational scaling problem, but it is a second system to operate.

GraphQL is for: many different clients over one API, screens with varied data needs, mobile clients on slow networks where every byte and every round trip counts, and organisations willing to operate a graph layer in exchange for client freedom.

gRPC: the typed contract

gRPC treats an API as a function call. Services and messages are defined in a .proto file, and the tooling generates a typed client and server stub in every supported language. Calls run over HTTP/2 — multiplexed streams on one connection, header compression, bidirectional streaming — and messages are encoded as Protocol Buffers, a compact binary format that is usually smaller on the wire than the equivalent JSON. The contract is the .proto file, and it is enforced by the compiler: if the client and server disagree, the build fails instead of the request.

// order.proto — the contract, shared by every language
syntax = "proto3";

package orders;

service OrderService {
  rpc GetOrder(GetOrderRequest) returns (Order);
  rpc StreamOrderEvents(StreamOrderEventsRequest)
      returns (stream OrderEvent);
}

message GetOrderRequest {
  string id = 1;
}

message Order {
  string id = 1;
  string status = 2;
  double total = 3;
}

// The generated stub makes the call feel like a local function
import { OrderServiceClient } from './generated/orders.client';

const client = new OrderServiceClient('orders.internal:50051');

const order = await client.getOrder({ id: '42' });
console.log(order.status, order.total);

// Streaming is a first-class call shape, not a bolt-on
for await (const event of client.streamOrderEvents({ orderId: '42' })) {
  console.log(event.type, event.at);
}

Four call shapes come with the framework — unary, server streaming, client streaming, and bidirectional streaming — and they are the reason gRPC dominates service-to-service traffic: a service can push a live event stream to another service with no polling, no WebSocket server to build, and no second protocol. Deadlines and cancellation propagate across the call chain, so a timeout at the edge cancels work deep inside the system instead of letting it run to completion unobserved. And because the interface is generated, renaming a field or changing a type is a compile-time event in every consumer.

The costs are the mirror image of REST's strengths. gRPC is a poor fit for browsers: browsers cannot speak native gRPC directly, so a browser client needs grpc-web or a gateway that translates to REST or JSON — an extra hop and an extra component. The binary wire format is not human-readable, so debugging means decoding with a tool rather than reading a curl response, and HTTP-level tooling (CDNs, caches, most API gateways) does not understand it — you need an HTTP/2-aware load balancer and a proxy that speaks gRPC, which is why the style pairs naturally with a service mesh. Versioning is disciplined but strict: fields are numbered, old numbers are never reused, and removing a field is a breaking change that the compiler will not catch for you if the old number is recycled. And the whole approach assumes the team controls both ends of the call — gRPC is a contract between services you own, not an invitation to the public internet.

gRPC is for: service-to-service calls inside one organisation, high-volume or latency-sensitive traffic, streaming workloads (live events, telemetry, chat), and polyglot systems where generated stubs in ten languages beat hand-written clients.

One request path, three choices at every layer Clients — browser · mobile app · service-to-service Wire — HTTP/1.1 + JSON · HTTP/2 + JSON · HTTP/2 + Protobuf Contract — OpenAPI · GraphQL schema (SDL) · .proto files Server — route handlers · resolvers · generated stubs Data — resource tables · graph resolvers · service methods The style is a stack of choices, not one decision — you can change the wire without changing the contract.

Head-to-head: REST vs GraphQL vs gRPC

RESTGraphQLgRPC
ContractURL space + media typeTyped schema (SDL).proto service definition
TransportHTTP/1.1 (HTTP/2 optional)HTTP, usually HTTP/2HTTP/2, mandated
PayloadJSON (or XML)JSONProtocol Buffers (binary)
Client decides shape?No — server fixes itYes — query picks fieldsNo — stub signature fixes it
Round trips for a screenOften severalOneOne per call
StreamingSSE / WebSocket bolt-onsSubscriptionsNative: four call shapes
CachingHTTP caching, CDNs — freeClient normalised cache, persisted queriesNone at HTTP layer
Browser supportNativeNativeNeeds grpc-web or a gateway
Code generationOptional (OpenAPI)Client types from schemaClient + server stubs from .proto
VersioningURL / media type versionsAdditive fields + deprecationField numbers, never reuse
Debuggingcurl, readable JSONPlayground, readable JSONBinary — needs decoding tools
Best forPublic, cacheable APIsMany varied clientsService-to-service at volume

The table hides the decision that matters most, which is not in any row: who owns the change. With REST, the server owns the shape and clients adapt; with GraphQL, clients own the shape and the server adapts; with gRPC, the contract owns the shape and both sides compile against it. Pick the ownership model that matches your organisation. A public API cannot let clients dictate the shape, so REST. A product with five clients and one backend team cannot afford five hand-built endpoints, so GraphQL. Ten services owned by ten teams cannot afford hand-written clients in ten languages, so gRPC.

Two other factors decide more real-world choices than any row of the table. The first is team size and skill: GraphQL's server-side costs (batching, query-complexity limits, federation) need a team that will operate a graph layer, and gRPC's tooling needs a team comfortable with code generation and HTTP/2-aware infrastructure. A two-person team shipping a public API should take REST and spend the saved effort on the product. The second is the traffic pattern: if the dominant call is a browser loading a page, REST or GraphQL; if it is a service calling another service a thousand times a second, gRPC; if it is a live feed, gRPC streaming or GraphQL subscriptions — and note that REST has no native answer there at all.

Decide by the caller, the payload, and the team What varies most? callers, payload, or team? Client data needs many screens, one API Service-to-service typed, high-volume calls Public, cacheable API third parties, CDNs GraphQL one query, exact fields gRPC stubs, streaming, deadlines REST URLs, HTTP caching, OpenAPI When two answers are true, pick the one that hurts less to change later — a gateway can translate.

Architecture decision: API style for a new service

  • Decision: Default to REST for anything public or cacheable; adopt GraphQL when one backend serves several clients with different data needs; adopt gRPC for service-to-service calls inside the organisation. Never adopt a style because it is fashionable — adopt it because the caller pattern matches.
  • Context: A multi-service system with a public API, several client applications (web, iOS, Android), and internal services that call each other. The team is small enough that operating three API styles at once would be a burden, so the decision has to name a default and the conditions that override it.
  • Options considered: (a) REST everywhere — one style, one skill set, HTTP caching everywhere. (b) GraphQL everywhere — one endpoint for all clients and services. (c) gRPC everywhere — typed contracts and streaming for every call. (d) The mixed default above: REST public, GraphQL for varied clients, gRPC between services.
  • Why this one: Option (a) forces the mobile team to make three round trips per screen or maintain aggregate endpoints that quietly become a query language. Option (b) forces service-to-service calls through a graph layer that adds latency and a single point of failure, and gives up HTTP caching for internal traffic that never needed client-shaped queries. Option (c) forces browser clients through a translation gateway and gives up CDN caching for the public API. Option (d) pays the cost of two styles, but each style is used where its strengths are real and its costs are irrelevant: REST's caching matters at the edge and not at all between services; gRPC's stubs matter between services and not at all to a browser.
  • What it costs you: Two (or three) skill sets to maintain, two sets of tooling to operate, and a gateway or backend-for-frontend layer where the styles meet — the GraphQL server resolves against REST or gRPC services behind it, and the public REST API may be a translation of the same operations. Observability has to span styles: a request that starts as a GraphQL query and fans out into gRPC calls needs one trace id carried through both.
  • When to reverse it: If the product ends up with one client and one backend, collapse to REST and delete the graph layer — GraphQL was overhead. If the service mesh already terminates gRPC and the public API has no caching requirements, a gRPC-first design with a REST translation gateway can replace the REST service. Revisit whenever a new client type appears: the second client is the signal that the shape decision needs re-checking, not the tenth.
  • Recommendation

    For a new service, apply the decision in this order. First, ask who calls it. If the callers are third parties, partners, or browsers hitting a CDN — REST, with an OpenAPI document generated from the code so it cannot drift. If the callers are your own apps and they keep asking for different slices of the same data — GraphQL, with query-complexity limits and DataLoader-style batching from day one, not added after the first incident. If the callers are your own services — gRPC, with deadlines set on every call and field numbers treated as permanent.

    Second, put a gateway in front of whichever style you pick. A gateway is where authentication, rate limiting, and request logging live once instead of in every service — our service mesh vs API gateway guide covers which one belongs where, and the same gateway is what translates gRPC to REST for browser clients when you need it. Third, decide the versioning story before the first client ships: additive fields and deprecation for GraphQL, field-number discipline for gRPC, and an explicit URL or media-type version for REST — because the first breaking change is when you discover whether you had a versioning story at all.

    For an existing service, the migration is incremental and safe. A REST API can grow a GraphQL layer in front of it: resolvers call the same handlers the REST endpoints call, and clients migrate one screen at a time — the REST endpoints stay live until the last client moves. A REST service can grow gRPC behind it: the service-to-service calls move to stubs while the public REST surface stays untouched. What you should not do is a big-bang rewrite of the API style, because the style is the contract, and every client has to move on the same day. Migrate the callers, not the contract, and retire the old surface only when its traffic is gone.

    When NOT to use each

  • Don't use REST when clients need different shapes of the same data. If every new screen needs a new aggregate endpoint or a ?fields= parameter list, you are rebuilding GraphQL badly. The ?fields= endpoint has no schema, no tooling, and no type safety — it is the worst of both styles.
  • Don't use GraphQL for service-to-service calls. Services do not need client-shaped queries; they need typed contracts, deadlines, and streaming. A graph layer between two services is latency and a failure mode with no benefit — use gRPC, or plain REST if the call volume is low.
  • Don't use GraphQL for a public API you cannot rate-limit properly. A single endpoint that executes arbitrary client-supplied queries is a denial-of-service vector until query-complexity analysis and persisted queries are in place. If you cannot operate those, REST's fixed endpoints are the safer public surface.
  • Don't use gRPC for browser clients. Browsers cannot speak it natively, so every browser call goes through a translation gateway — an extra hop, an extra component, and a second contract to keep in sync. Serve browsers REST or GraphQL and keep gRPC behind the gateway.
  • Don't use gRPC for a public API. The binary format is opaque to the HTTP ecosystem: no CDN caching, no curl debugging, no API gateway that understands the calls without specific support. A public API should be readable and cacheable — that is REST's job.
  • Don't mix all three in one service. One service, one style, with translation at the boundary. A service that exposes REST, GraphQL, and gRPC endpoints for the same operations has three contracts to version, three surfaces to secure, and three sets of client bugs. The mixed default above is a system-level decision, not a per-service one.
  • REST, GraphQL, and gRPC are not rungs on a ladder — nothing is "more modern" about any of them, and the team that picks gRPC for a public API or GraphQL for service-to-service calls has mistaken novelty for fit. The durable skill is reading the caller pattern: public and cacheable, many clients with different needs, or services talking to services. Name the callers first, and the style picks itself. For the decision that comes before this one — how the services themselves are organised — our modular monolith vs microservices guide is the place to start; and when the answer to "which API style" is "none of them, this should be asynchronous", our event-driven microservices guide covers the queue-and-event alternative.

    Why This Matters

    Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.

    Trade-offs to Consider

    Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.

    When NOT to Use This

    Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.

    Decision Framework

    Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.

    Share this articleShare on XShare on LinkedIn

    Keep the decision frameworks coming

    One practical architecture guide a week — patterns, trade-offs, and when not to use them. No spam, unsubscribe anytime.