REST vs GraphQL vs gRPC: Choosing an API (System Design)
Where the API step fits in a system design interview, how REST, GraphQL and RPC differ, and three questions that pick the right one, with a ticket-booking…
Choosing an API protocol: common questions
Should I use REST, GraphQL or gRPC in a system design interview?
Default to REST for anything browsers or phones call. Pick GraphQL when many clients need very different slices of the same data. Use gRPC between your own internal services. Add WebSockets or SSE only for live updates.
How long should the API part of a system design interview take?
About five minutes. Turn each requirement into one or two endpoints, show sensible names and where data goes, then move on to the high-level design.
Related chapters
- Start here in System Design
- How a system design interview is graded
- The delivery framework: five phases and a clock
- Numbers to know: what one machine can really do
- System Design Concepts: CAP, SQL vs NoSQL, Message Queues
- SQL vs NoSQL: How to Choose a Database (System Design)
- Traffic Jumps 10×: What Breaks First? (System Design)
- Proxy vs Load Balancer vs API Gateway (System Design)
- CAP Theorem Explained Simply, with Examples
- Why Use a Message Queue? System Design Explained
- Message Queue vs Pub/Sub vs Kafka: Differences
- Polling vs Long Polling vs SSE vs Webhooks (System Design)
- API design in System Design
- API Goals Canvas: Design APIs from the Consumer
- REST API Design: Resources, Methods, Status Codes
- HTTP Semantics, Richardson Maturity Model and HATEOAS
- GraphQL Explained: Over-fetching, Schema, N+1 Problem
- RPC and gRPC Explained: Protobuf, HTTP/2, When to Use
- API Design Best Practices: 9 Principles with Examples
- API Payload Design: Names, Types, Links and Errors
- Mapping Database Tables to API Resources, Step by Step
- API Design for Complex Schemas: Trees, Polymorphism, Bookings
- API Pagination, Idempotency Keys, Errors and Versioning
- Network-Efficient APIs: HTTP Caching, ETags, Field Selection
- Async APIs: 202 Accepted, Webhooks and Bulk Operations
- API Versioning and Evolution Without Breaking Clients
- API Contracts: OpenAPI, Contract Testing and Docs
- API Security: Authentication, Authorization, Rate Limiting
- OAuth 2, OpenID Connect and Scopes for APIs
- OWASP API Top 10 Explained: BOLA, SSRF and More
- Running APIs: Gateways, Mesh, Rate Limits, Canaries
- API Troubleshooting Interview: Slow APIs and Unexpected Errors
- API Design Review: A Staff-Level Capstone
- Spotify Web API: Resources, IDs, Payloads and Paging
- Spotify Web API: OAuth PKCE, Scopes, Quotas, Rate Limits
- Spotify Web API Changes: Real API Evolution Lessons
- Database-heavy designs in System Design
- Design a Distributed Key-Value Store (System Design Interview)
- Design a Hotel Reservation System (System Design Interview)
- Design a Digital Wallet (System Design Interview)
- Design S3-like Object Storage (System Design Interview)
- Games in System Design
- Shard City: Learn Database Sharding by Playing a Game
- System Design Case Studies: Flash Sale, Chat, ChatGPT
- Flash Sale System Design: Who Gets the Last Item
- Food Delivery App System Design: Which Database?
- Cache Stampede: Why the Database Fell Over and the Fix
- Live Streaming System Design: Scaling for a Final
- ChatGPT System Design: Streaming LLM Responses
- RAG System Design: Product Q&A on Sale Day
- IRCTC Tatkal System Design: Booking Under Extreme Load
- Group Chat System Design: WebSockets and Fan-Out
- Authentication in System Design: Sessions, JWT, OAuth
- Authentication Methods Compared: Sessions, JWT, OAuth
- JWT in System Design: Sessions, Revocation, Refresh Tokens
- JWT Interview Questions and Answers
- Life of a session, step by step
- JWT Structure Explained: Header, Payload, Signature
- Forge lab: why verification must be strict
- JWT vs Session Authentication: Which to Use
- The validation pipeline: where a bad request dies
- How to Revoke a JWT: Blocklists and Short Expiry
- Refresh Tokens and Rotation Explained
- Logout in depth: one device, all devices, SSO
- JWT Security Best Practices
- OAuth 2.0 and OpenID Connect Explained
- Where to Store JWT: localStorage vs HttpOnly Cookie
- JWT in Microservices: API Gateway vs Service Validation
- Microservices, keys, and trust boundaries
- Sender-constrained tokens: making a stolen token useless
- Authentication vs Authorization Middleware
- Failure explorer: what breaks when X fails
- Capacity planner: sessions vs JWT vs hybrid
- Edge cases catalog
- Test it, measure it, migrate to it
- Anti-patterns to reject in a design review
- Design checklist and cheat sheet
Keep learning
Overview
RPC (gRPC) Only your own services call it. You control both sides, so you can use a fast binary format and a shared contract file. Browsers never see it. Many screens want very different slices of the same data. Letting each screen ask for exactly its fields saves extra round trips and wasted bytes. Browsers and phones call it, and the screens want roughly the same data. REST is what every developer already knows, works with every tool, and caches well. Lab: answer three questions, get a protocol 1. Who calls this API? Browsers, phone apps or other companies Only our own services, inside our servers 2. Do different screens need very different data? No, mostly the same fields Yes, each screen wants its own mix No, the client asks when it needs something Yes, the server must push + WebSockets or SSE for the live part Pick an answer for each question to see the result.
REST, GraphQL or RPC: picking the protocol
An API is the list of things a client is allowed to ask your system to do. This chapter shows where the API fits in the interview, the three common styles, and a three-question way to choose one.
What an API is
Think of a restaurant. You don’t walk into the kitchen. You read the menu, tell the waiter what you want, and food comes back. An API is that menu for software: a fixed list of requests a client may send, and what it gets back for each one. All through this section we use one example: a ticket booking site like Ticketmaster. People search for concerts, open an event page, pick seats and book. When the phone app opens the page for event 123, this happens: Phone app the client GET /events/123 the request: “give me event 123” looks it up in the database the response, as JSON A request goes out, a response comes back. The API decides which requests exist and what each returns.
Where the API fits in the interview
In a system design interview you first agree what the product must do (the requirements), then list the main things it stores (the entities: Event, Venue, Ticket, Booking). The API comes next, and it should take about five minutes. You turn each requirement into one or two requests: Each requirement becomes an endpoint (one request the API accepts) Users can search for events GET /events?query=coldplay Users can view an event GET /events/123 Users can see free seats GET /events/123/tickets Users can book seats POST /events/123/bookings The interviewer does not want every header and field. They want to see that the requests match the requirements, the names make sense, and you know where each piece of data goes. Save your time for the design that comes after.
Three styles of API
The menu can be written in three common styles. Each one solves a different problem, so it helps to know what each is good at. the default Every thing (an event, a booking) has its own address, like /events/123. You use a small set of verbs on it: GET to read, POST to create, DELETE to remove. client picks fields One single address. The client sends a little query that lists exactly which fields it wants, and gets back that shape and nothing more. Here is the same job, “get event 123 with its venue name”, in all three: REST: two requests GraphQL: one query, exact fields Notice the difference in thinking. REST talks about things (events, venues). GraphQL talks about the shape of data you want. RPC talks about actions (get, create). The next three chapters go through each one.
How to choose
Start with REST. It is the safe default for anything a browser or phone calls, and most interviewers expect it. Move away from it only when a question below gives you a reason. Try it: For our ticket site the answers are: browsers and phones call it, screens want similar data, and the seat map may change live. So: REST for the public API, maybe SSE for live seat updates, and gRPC between our own services behind the scenes.
Say it in the interview
“I’ll use REST for the public API since browsers and mobile apps call it and the data is resource-shaped. Internally services can talk over gRPC. If we need live seat updates I’d add SSE for that one screen.” That one sentence shows you know all three and chose on purpose. Next, before writing any URL: what the people calling the API need to get done. Spotify’s resource map GitHub’s GraphQL API shows what the other style costs to run. GitHub GraphQL limits
More courses
- Jobs, linked to lessons — Browse jobs where every requirement links to the chapter that teaches it. See how ready you are, how long the gap takes to close, and which listings look stale.
- Match a job post to courses — Paste a job post. Each skill is matched to a track here and put in learning order, foundations first.
- React from open source with patterns — Patterns extracted from Material UI, Radix, React Aria, React Hook Form, Redux Toolkit, TanStack, and Next.js — not slides about hooks.
- Database in depth — How a query becomes work. Indexes, isolation, locks, and the plans that explain why a page is slow — not an ORM tour.
- Build a real API with NestJS — One ticket-booking API, built in order: a plain Node server first, then NestJS modules, validation, a real database, and the features real clients lean on.
- Microservices — Microservice patterns one diagram at a time: how to split a monolith, how services talk, and how data stays consistent without distributed transactions.
- Kafka — A beginner-to-senior path through event logs, reliable delivery, production operations, and disaster recovery.
- AI engineering for software engineers — Eight free reads, in order, for software engineers moving into AI: when to build an agent, how to build one, how to test it, and how the model works underneath.
- Frontend system design — How a UI is sliced when it is a product, not a page: ownership of state, cache, routes, and what happens when the network lies.
- TypeScript in depth — The type system as a design tool. Inference, narrowing, generics, and the errors that mean the model is wrong — not a catalog of utility types.
- CSS in depth — See the box, then the page. Visual chapters from the box model through Flexbox surprises, Grid, selectors, and units, then backgrounds, shapes, and visual effects, each with a playground.
- Accessibility — Foundations first (WCAG in plain words, semantic HTML, lists, alt text), then hands-on HTML labs, a full pass of WAI-ARIA 1.3, and a final fix-the-page challenge.
- Docker — What an image is, why layers cache, and how containers find each other on a network.
- Redis — Fifteen Redis patterns, one picture each: cache, session, lock, counter, rate limiter, queue, and when Redis is the wrong tool.
- Kubernetes — Kubernetes from zero to operators: why it exists, Pods, Deployments and Services, then configuration, networking, storage, scheduling, scaling and security.