Backend and APIs · Comparison
REST vs GraphQL vs tRPC vs gRPC
Four ways for apps and services to ask a backend for data. They differ in who can call them, how strictly the contract is typed, and what travels over the wire.
4 options · 7 questions side by side · updated
| Compare | REST | GraphQL | tRPC | gRPC |
|---|---|---|---|---|
| Shape | A URL for each resource | One endpoint; queries name the fields | TypeScript functions called over HTTP | Functions defined in .proto files |
| Data format | Usually JSON | JSON | JSON | Protocol Buffers (binary) |
| Contract | Optional (OpenAPI) | Typed schema, required | Inferred from TypeScript code | .proto files, required |
| Clients | Anything that speaks HTTP | Any language, with client libraries | TypeScript only | Many languages; browsers need a proxy |
| Caching | Standard HTTP and CDN caching | Needs client-side caching | Client-side, often TanStack Query | Not cached by HTTP tools |
| Best for | Public APIs and most apps | Many clients needing different data | Full-stack TypeScript apps | Traffic between services |
| Watch out for | Over- or under-fetching data | Complexity and expensive nested queries | Ties both ends to TypeScript | Harder debugging and browser support |
How to choose between REST, GraphQL, tRPC and gRPC
- Pick REST for public APIs and whenever many kinds of client will call the backend.
- Pick GraphQL when several apps need different views of deeply linked data.
- Pick tRPC when one team writes both ends in TypeScript and wants types to flow automatically.
- Pick gRPC for efficient, strictly typed calls between internal services.
The options
- RESTThe usual style of web API: each kind of thing has its own URL, and standard HTTP methods such as GET and POST read and change it.
- GraphQLA query language for APIs where the app asks one endpoint for exactly the fields it needs and gets data back in that same shape.
- tRPCA TypeScript library that lets the frontend call backend functions directly with full type checking, without writing a schema or generating code.
- gRPCAn efficient, strictly typed way for services to call each other's functions over the network, using compact binary messages instead of JSON.
More comparisons
- Node.js vs Deno vs BunThree runtimes for JavaScript and TypeScript on the server. Much of the same code runs on all three; they differ in built-in tools, security defaults, speed and how long each has been used in production.
- Express vs Fastify vs HonoThree JavaScript web frameworks with a similar feel. Express is the long-standing default, Fastify focuses on throughput and structure, and Hono is built on web standards so it can run almost anywhere.
- FastAPI vs Django vs FlaskThree widely used Python web frameworks. Django includes almost everything, Flask includes almost nothing, and FastAPI focuses on typed, self-documenting APIs.
- WebSockets vs SSE vs webhooksThree ways to deliver news the moment it happens. WebSockets and SSE push updates to browsers and apps; webhooks push events from one server to another.
- Sessions vs JWTBoth keep a person signed in after they log in. A session keeps the facts on the server and gives the browser a random key; a JWT packs the facts into a signed token that the client carries around.
- Magic link vs OTP vs passkeys vs social loginFour ways to let people in without asking them to invent a password. They differ in how many steps they take, what they cost to run and how well they stand up to phishing.
Crafted in the dark. Shipped to the world.
Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.