Skip to content

REST vs GraphQL vs gRPC vs tRPC: how each one works, where it hurts and how to choose for your API

How REST, GraphQL, gRPC and tRPC work inside, what each one solves, where each one hurts (N+1, the browser, public APIs) and the question that decides: who consumes your API.

Ramon Gomes 12 min read Level: Intermediate

Also available in: Español, Français, Português

"Should we do it in GraphQL?" is a question I've seen wreck weeks of a schedule. The four styles in this article solve different problems, and the wrong choice doesn't show up on day one. It shows up when a client from another company can't integrate, when a screen fires 300 database queries or when the browser doesn't speak the protocol.

The API concepts article has a one-line summary of each style. Here I go deeper: how each one works inside, what it solves, where it hurts, the myths going around and how to choose. Versions and data checked on November 21, 2026.

Table with several power plug adapters from different countries spread out next to a laptop and a charger, seen from above
The power is the same. The shape of the plug changes depending on who's going to use it.

The Question That Decides: Who Consumes Your API?

Before comparing technology, answer this:

  • Third parties, using different languages and from different companies? You need a neutral contract you can document. REST with OpenAPI is the safest path.
  • Your own screens, with lots of data combinations? GraphQL starts to make sense.
  • Your other services, talking a lot and fast? gRPC.
  • Only your TypeScript front end, in the same repository? tRPC.

Almost every bad choice I've seen came from picking the trendy style instead of looking at who consumes the API.

REST: Much More Than JSON Over HTTP

REST was born in Roy Fielding's doctoral dissertation in 2000. It's not a protocol or a format. It's an architectural style, defined by constraints. The main ones:

  • Client and server are separate.
  • Stateless: each request carries everything the server needs.
  • Cache: the response says whether it can be stored or not.
  • Uniform interface: resources with addresses, manipulated through representations, with self-descriptive messages and hypermedia guiding the next step.
  • Layers: the client doesn't know if it's talking to the final server or to an intermediary.

None of them mention JSON. And Fielding himself was blunt in 2008: an API whose state isn't driven by hypertext "cannot be RESTful". For him, most of what we call REST is RPC over HTTP.

The most useful way to see this is the Richardson Maturity Model, popularized by Martin Fowler:

Isometric staircase with four servers, from level 0 to 3, and cards with HTTP examples: POST /api; POST /orders/42/cancel; DELETE /orders/42 with a 204 No Content response; and a response with links. Level 2 is highlighted as the point where most APIs stop.
Most APIs out there stop at step 2, and that's fine.
Level What changes Example
0 HTTP only as transport POST /api with {"action": "cancelOrder"}
1 Resources POST /orders/42/cancel
2 HTTP verbs and status codes DELETE /orders/42 returns 204 or 404
3 Hypermedia The response includes "links": {"pay": "/orders/42/payment"}

Fowler himself warns that the model is a learning tool, not an official definition of REST. In practice, level 2 already delivers the main benefits: working HTTP caching, error codes every client understands and ready-made tooling.

Where REST shines: public APIs, integration between companies, CDNNetwork of servers spread around the world that keeps copies of files and pages close to users, serving them faster and offloading the origin server. caching, any client in any language. With OpenAPI (version 3.2, from September 2025, which added the QUERY method and streaming support), the contract becomes a document, generates clients and feeds tests.

Where it hurts: a screen that needs data from five resources makes five calls, and each one brings fields the screen doesn't use.

GraphQL: The Client Picks the Dish

GraphQL was created at Facebook in 2012, open sourced in 2015 and is now maintained by the GraphQL Foundation, under the Linux Foundation. The specification got its September 2026 edition.

The core idea: a single endpoint, a typed schema and the client writing the query with exactly the fields it wants.

Two columns compare REST and GraphQL. On the left, three response envelopes contain 15 fields, with four selected and 11 unused. On the right, one GraphQL query selects the total, customer name, product and quantity. Both routes build the same screen: total of $120.00, Ana Souza and 2x Coffee.
With REST, the screen assembles what it needs from several responses. With GraphQL, it asks only for what it will use.
graphql
query {
  order(id: 42) {
    total
    customer { name }
    items { product { name } quantity }
  }
}

This solves over-fetching (too much data) and under-fetching (needing several calls). But it trades them for three problems that the official documentation itself describes:

1. N+1. To list 50 orders with the customer name, a naive server runs 1 query for the orders and 50 more, one per customer. The documentation calls this service "chatty". The standard fix is DataLoader, which batches the lookups made at the same moment and sends a single query.

Two flows connect GraphQL racks to cylindrical databases. Above, one query fetches 50 orders and a grid of 50 per-customer queries results in 1 + 50 = 51 queries. Below, a DataLoader funnel batches requests made at the same moment into WHERE id IN (1..50), for 1 + 1 = 2 queries.
Without DataLoader, each item becomes a query. With it, they all become one.

2. Expensive queries. Since the client builds the query, it can nest lists inside lists, and the cost grows exponentially. The documentation recommends limiting depth and calculating the cost of each query before running it.

3. Caching. Standard HTTP caching works with GET and a stable URL. With GraphQL, that requires persisted queries (the client sends a hash and the server already knows the query). And they only work when you know your clients, so they're no good for a public API.

A security detail that comes up in every conversation: turning off introspection (the feature that exposes the schema) in production is, in the documentation's words, "security through obscurity". It helps, but it doesn't replace authorization on every field.

Where GraphQL shines: products with many screens and clients (web, app, admin panel) pulling different data from the same domain. Where it hurts: a simple CRUD API, third-party integration, a team with no time to take care of performance and security.

gRPC: Strict Contract, Fast Conversation

gRPC is a CNCF project. The contract lives in a .proto file (Protocol Buffers), messages travel in binary and the transport is HTTP/2. Client and server code in several languages come out of the same file.

protobuf
service Orders {
  rpc Get (GetOrder) returns (Order);                          // unary
  rpc Track (GetOrder) returns (stream Status);                 // the server sends many
  rpc SendItems (stream Item) returns (Summary);               // the client sends many
  rpc Chat (stream Message) returns (stream Message);          // both at the same time
}
Four lanes with phones, servers and envelopes show the gRPC call types: unary with one request and one response; server streaming with one request and many responses; client streaming with many messages and one response; bidirectional with simultaneous messages in both directions.
The four ways to talk in gRPC. The last one is what REST can't do without a hack.

The browser myth. Saying gRPC doesn't work in the browser is a half truth. It works in two ways:

Three routes between browser windows and server racks: plain gRPC meets a barrier; gRPC-Web passes through an Envoy appliance, with a warning that client and bidirectional streaming are unavailable; Connect links browser and server directly, without a proxy.
The browser doesn't speak plain gRPC. With gRPC-Web or Connect, it does.
  • gRPC-Web, with a proxy like Envoy doing the translation. Official limitation: client streaming and bidirectional streaming aren't supported.
  • Connect RPC, a CNCF project that serves gRPC, gRPC-Web and its own protocol with no proxy needed.

Where gRPC shines: communication between internal services, many languages, streaming, low latency. Where it hurts: debugging binary with curl, a public API for people who don't want to generate a client, the browser without an extra layer.

tRPC: The Types Cross the Network

tRPC (version 11.29 in November 2026) has no schema and no code generation. The client imports the type of the server's router, and TypeScript does the rest:

ts
// server
export const appRouter = router({
  orderById: publicProcedure
    .input(z.string())
    .query(async ({ input }) => getOrder(input)),
});
export type AppRouter = typeof appRouter;

// client
import type { AppRouter } from '../server/router';
const trpc = createTRPCClient<AppRouter>({ links: [httpBatchLink({ url: '/api/trpc' })] });
const order = await trpc.orderById.query('42'); // typed end to end
Two editor monitors linked by the AppRouter type. On the server, total: 120 is renamed to totalAmount: 120. On the front end, order.total has a red underline and a suggestion to use totalAmount. A timeline places the TypeScript warning before build and deploy, without code generation.
Change it on the server and the front end complains in the editor. No code generation, no waiting for the deploy.

The day to day experience is excellent: rename a field on the server and the front end editor points out the error right away. It pairs really well with tests and types as a safety net.

The limit is a direct consequence of the design: the contract is a TypeScript type. Anyone who doesn't compile TypeScript with access to that type (a Kotlin app, a partner using Python) gets nothing out of it. The documentation requires TypeScript 5.7.2 or later and strict mode.

Where tRPC shines: a monorepo with front end and back end in TypeScript, a small team, an internal API. Where it hurts: any consumer outside that circle.

Side by Side

REST GraphQL gRPC tRPC
Contract OpenAPI (optional) Required schema Required .proto TypeScript type
Format Any, almost always JSON JSON Binary (Protobuf) JSON
HTTP caching Natural Needs persisted queries Doesn't apply Limited
Streaming With separate SSE or WebSocket Subscriptions Native, 4 types Subscriptions
Browser Yes Yes With gRPC-Web or Connect Yes
Client languages All All All with a generator TypeScript only
Best for Public API and integration Many screens and clients Service to service TypeScript monorepo

And you can mix them. It's common to see REST facing outward, gRPC between services and GraphQL or a Backend for Frontend in front of the screens.

The Other Names That Come Up

  • JSON-RPC 2.0: function calls in JSON, not tied to any transport. It's the foundation of MCP, the protocol that connects tools to AI models.
  • AsyncAPI 3.1: the "OpenAPI of the async world", for describing event and queue APIs.
  • Webhooks, WebSocket and SSE: they aren't competing styles, they're channels for the server to notify the client. In the 2025 Postman survey, webhooksHTTP call a system makes to your address when something happens, like an approved payment, notifying you right away instead of you polling for changes. show 50% usage and WebSockets 35%.
Cartoon of four people trying to plug the same device into the same outlet, each holding a plug of a different shape and arguing, while a calm fifth person offers a universal adapter
The argument ends when someone asks who's going to use the outlet.

Quick check

1. According to the Richardson model, what defines level 3?
Show answer

Answer: The response carrying links to the possible next steps

It's the hypermedia level. For Fielding, it's a requirement for calling the API REST.

2. What does DataLoader solve in GraphQL?
Show answer

Answer: The N+1 problem, merging several lookups into a single query

It batches the lookups made at the same moment and sends a single query to the database.

3. Why is tRPC no good for a public API?
Show answer

Answer: Because the contract is a TypeScript type, which only helps those who compile TypeScript with access to it

Without a neutral schema, a partner using another language has no contract to follow.

Frequently Asked Questions

Is GraphQL faster than REST?

Not by nature. It saves calls and fields, but it can be slower on the server if N+1 and expensive queries aren't handled. HTTP caching is also harder.

Does gRPC replace REST?

For communication between internal services, often yes. For a public API and the browser, rarely: REST is still simpler to consume and debug.

Can I use tRPC and REST together?

Yes. It's common to use tRPC between the front end and back end of the same product and expose REST for integrations.

What is OpenAPI and do I need it?

It's the specification that describes a REST API in a YAML or JSON file. It isn't mandatory, but it generates documentation, clients and tests. For a public API, I consider it essential.

Which one should I learn first?

REST, in depth: HTTP, verbs, status codes and caching. Everything else builds on that. The list of free back-end courses has good starting points.

References

Checked on November 21, 2026:

Source: https://ramongomessilva.com.br/blog/rest-vs-graphql-vs-grpc-vs-trpc · Accessed on December 02, 2026

Share Share on LinkedIn Share on X
Cite this article

Ready-made reference, with today as the access date.

ABNT

Brazilian standard (NBR 6023). Use it in theses and academic papers submitted in Brazil.

GOMES, Ramon. REST vs GraphQL vs gRPC vs tRPC: how each one works, where it hurts and how to choose for your API. Ramon Gomes, 27 nov. 2026. Disponível em: https://ramongomessilva.com.br/blog/rest-vs-graphql-vs-grpc-vs-trpc. Acesso em: 2 dez. 2026.

APA

American Psychological Association style. Common in scientific papers and journals, especially in the social, behavioral and health sciences.

Gomes, R. (2026, November 27). REST vs GraphQL vs gRPC vs tRPC: how each one works, where it hurts and how to choose for your API. Ramon Gomes. https://ramongomessilva.com.br/blog/rest-vs-graphql-vs-grpc-vs-trpc

BibTeX

Format for LaTeX users (Overleaf, for example). Paste it into your .bib file or import it into Zotero or Mendeley.

@online{gomes2026restvsgraphql,
  author = {Gomes, Ramon},
  title = {{REST vs GraphQL vs gRPC vs tRPC: how each one works, where it hurts and how to choose for your API}},
  organization = {Ramon Gomes},
  year = {2026},
  month = nov,
  date = {2026-11-27},
  url = {https://ramongomessilva.com.br/blog/rest-vs-graphql-vs-grpc-vs-trpc},
  urldate = {2026-12-02}
}
Found a mistake?

Wrong fact, broken link, outdated information: tell me and I will fix it.

10 to 2,000 characters. If you can, point to the right source.

Only so I can reply. It never shows on any page of the site.

Written by

Ramon Gomes

Software Engineer

Full stack software engineer. I like taking a messy problem, listening to the people who live with it and shipping something that holds up day to day. These days I split my time between my own products, applied AI and client work.

Available for projects

Need Something Like This Built?

I build websites, systems, apps and AI automations, from design to deploy. Tell me what you need or see what I offer.

Related Articles