CONCEPT SHEET · Concepts

API Design: REST vs GraphQL vs gRPC

One-liner: REST is resource-oriented over HTTP; GraphQL is a client-shaped query language; gRPC is binary RPC over HTTP/2 with Protobuf.

ArticleConcepts© Arthur Bernier Jr593 words2 code blocks

Say this#

How it works#

TEXT
REST:     GET /users/42/orders?cursor=abc&limit=20   -> JSON, cacheable by URLGraphQL:  POST /graphql { user(id:42){ name orders(first:20){ id } } } -> exactly those fieldsgRPC:     OrderService.ListOrders(ListOrdersRequest{user_id:42}) -> binary protobuf over HTTP/2
  • REST: stateless, uniform interface, HTTP caching (ETag, Cache-Control) works out of the box.
  • GraphQL: single endpoint, client specifies shape, resolvers fetch per field; persisted queries for caching.
  • gRPC: contract-first .proto, codegen in many languages, HTTP/2 multiplexing, deadlines/cancellation built in; needs gRPC-Web or a gateway for browsers.

Trade-offs#

ChoiceProCon
RESTUbiquitous, cacheable, simple toolingOver/under-fetching, many round trips, loose contracts
GraphQLOne round trip, exact shape, strong schema, great for varied clientsCaching harder, N+1, complexity/cost of arbitrary queries, auth per field
gRPCFast (binary, HTTP/2), strict contracts, streaming, deadlinesNot browser-native, less human-readable, needs proxy for public web
Cursor paginationStable under inserts, O(1) seekNo "jump to page N"
Offset paginationSimple, jump to pageSlow at depth, skips/dupes under writes

Numbers#

  • Protobuf payloads commonly 3-10x smaller than equivalent JSON; parse cost lower by similar order.
  • HTTP/2 multiplexes many streams over one TCP connection; HTTP/1.1 browsers cap ~6 connections/host.
  • Typical public API rate limits quoted per key: hundreds to thousands of req/min.

In the interview#

See also