LearnThatStack Ace your next interview
API Design · question
Question 1 of 110

What is REST and what are its core principles?

beginner
← All API Design questions
Re-explain
Visual ↓

REST (Representational State Transfer) is an architectural style for distributed systems, defined by Roy Fielding in 2000. It is a set of constraints, not a protocol or a standard.

Six constraints define the style:

  • Client-server: the two sides evolve on their own.
  • Stateless: each request carries everything the server needs.
  • Cacheable: responses must say if they can be stored and reused.
  • Uniform interface: one consistent way to address and act on resources.
  • Layered system: a client cannot tell if it talks to the origin server.
  • Code on demand (optional): the server may send runnable code, like JavaScript.

Every request stands alone, as this one does:

GET /articles/42 HTTP/1.1
Host: api.example.com
Authorization: Bearer <token>
Accept: application/json

Statelessness is the main trade-off. Any server node can handle any request, but each call must resend auth and context.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for API Design One question at a time. Answer out loud, get graded, see what you missed.
Related concept

Thinking in resources: what REST actually is

REST is constraints, not JSON over HTTP: address resources, let methods decide the action, send hypermedia links to what's next and more.

For this question · all 3 chaptersThree things: five constraints define REST, resource naming and hypermedia.

1/3 REST is a set of constraints
CONSTRAINTSREST is a set of constraintsfive constraints make an api RESTFULRESTclient-servercacheableuniform interfacelayered system
CONSTRAINTSREST is a set of constraintsRESTclient-servercacheableuniform interfacelayered system

REST is a set of constraints

  1. Ask an engineer what REST is and you usually get a tool list: JSON, HTTP verbs, a URL scheme. That list cannot tell a RESTful API apart from any other API that sends JSON.
  2. REST is a set of constraints. First is client-server: the client owns the interface, the server owns the data. Next is Stateless which means every request has everything the server needs to answer it. So any instance behind the load balancer can take the next request.
  3. Next is Cacheable. It means a response indicates whether a client or a proxy may keep a copy, so repeated reads never reach your server. Then, Uniform interface - it refers to the shape and structure: resources at addresses, standard methods, and links in the response.
  4. Layered system is the fifth constraint. A client cannot tell whether it is talking to the origin server, a cache, or a load balancer in front of that server. This is REST - all these five constraints combined.
  5. Assume a design broke one of these constraint. For example - a WebSocket connection holds session state on the server between messages, to know which client is connected, and what that client last saw. A request on that connection no longer carries everything needed to answer it, so its no longer stateless.
  6. So you gave up the stateless constraint to keep the connection open. The other four are still good, and the design is right for the use case. WebSockets are the right call for a live chat feed.
  7. Even though four of the constraint are still good, and the API still sends JSON over HTTP. This is a WebSocket design, not REST.
Chapter 1 · step 1 of 7

Ask an engineer what REST is and you usually get a tool list: JSON, HTTP verbs, a URL scheme. That list cannot tell a RESTful API apart from any other API that sends JSON.

1 of 7 Use ← → or swipe See the concept

© LearnThatStack - diagrams may not be republished without permission.

How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

  • Most APIs called REST never return hypermedia links. Are they really RESTful? Name HATEOAS as part of the uniform interface, admit they fall short by Fielding's definition, and say why teams skip it anyway.
  • If REST is stateless, how does a logged-in user stay logged in? Each request carries a token the server can verify. Say why server-side sessions break the rule and what a shared session store costs.
  • How does the cacheable constraint show up in real HTTP responses? Cache-Control and ETag headers, conditional GETs that return 304, and why GET responses cache while POST responses usually don't.
  • Is REST tied to HTTP? Could you build a RESTful system on another protocol? REST is a style and HTTP is one protocol that fits it well. The constraints never name HTTP, though almost every real REST API uses it.
  • When would you choose GraphQL over a REST API? Clients that need nested data in one round trip or pick their own fields, and what you lose, mainly plain HTTP caching on GET URLs.

What you can say

  1. REST is an architectural style that Roy Fielding defined in 2000. It's a set of constraints, not a protocol or a standard.
  2. Client and server are separate so each can evolve on its own, and every request is stateless, meaning it carries everything the server needs.
  3. Responses have to say whether they can be cached, and a uniform interface gives you one consistent way to address resources and act on them.
  4. It's a layered system, so a client can't tell if it's talking to the origin server or something in between, and code on demand, like sending JavaScript, is the one optional constraint.
  5. So a request like GET /articles/42 with a bearer token and an Accept header stands on its own.
  6. Statelessness is the main trade-off. Any server node can handle any request, which makes scaling out simple, but every call has to resend auth and context.

Weak answers to avoid

  • Says REST means JSON over HTTP REST is a set of constraints, not a format or a protocol. Name the constraints and treat JSON and HTTP as common choices, not the definition.
  • Lists CRUD verbs instead of constraints Mapping GET, POST, PUT and DELETE to CRUD is one slice of the uniform interface. Name the constraints and say what statelessness costs.
  • Confuses stateless with no stored data Stateless doesn't mean no database. It means the server keeps no client session between requests, so each request carries its own auth and context.
  • Recites six names with no trade-off A memorized list sounds rehearsed. Tie at least one constraint to a consequence, like statelessness letting any node serve any request.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the API Design cheatsheet.

← Back to all API Design questions
Pro · $10/mo

90 of 110 API Design answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime