REST Principles0%

REST Principles

Beginner12 min read•Updated: Jul 11, 2026
Study MaterialsCheatsheet

REST Architectural Principles and Statelessness

Representational State Transfer (REST) is an architectural style designed by Roy Fielding in 2000 for distributed hypermedia systems. REST governs how modern web services communicate over HTTP, enabling clients (web SPAs, mobile apps, IoT devices) and backend servers to interact reliably, securely, and scalably.


1. The Six Guiding Architectural Constraints of REST

To be considered a true RESTful system, an API architecture must satisfy six constraints:

Output
┌─────────────────────────────────────────────────────────────┐
│ SIX REST ARCHITECTURAL PILLARS │
├─────────────────────────────────────────────────────────────┤
│ 1. Client-Server Separation (UI concerns decoupled from db) │
│ 2. Statelessness (Each request carries complete context) │
│ 3. Cacheability (Responses explicitly declare caching rules)│
│ 4. Uniform Interface (Resource URIs, representations) │
│ 5. Layered System (Proxies, gateways, CDNs transparent) │
│ 6. Code on Demand (Optional: sending executable scripts) │
└─────────────────────────────────────────────────────────────┘

2. The Core Principle: Statelessness

Statelessness mandates that no client session context is stored on the server between requests. Every single incoming request must contain all the information necessary for the server to understand, authenticate, and process it.

Stateful vs Stateless Comparison:

Output
Stateful Architecture (Anti-pattern for scalable APIs):
Client ──► "Log me in" ──► Server creates session in memory (Session ID: 101)
Client ──► "Show my invoices" (Cookie: 101) ──► Server looks up memory for 101
* Problem: If Server A crashes or traffic is routed to Server B, session 101 is lost!
 
Stateless Architecture (RESTful):
Client ──► "Log me in" ──► Server issues signed cryptographic JWT token
Client ──► "Show my invoices" (Authorization: Bearer <JWT>)
* Benefit: ANY server instance can verify the signature and process the request independently!

3. Uniform Interface & Resource-Oriented URIs

In REST, everything is a Resource. Resources are identified by stable, noun-based URIs (never verbs or actions):

Bad URI (RPC / Action-based)Good RESTful URI (Resource-based)HTTP Method
/api/getInvoices/api/v1/invoices/GET
/api/createInvoice/api/v1/invoices/POST
/api/updateInvoice?id=4/api/v1/invoices/4/PUT or PATCH
/api/deleteInvoice/4/api/v1/invoices/4/DELETE

4. Richardson Maturity Model

The Richardson Maturity Model breaks down the progression towards true REST:

  • Level 0 (The Swamp of POX): Single HTTP endpoint with raw RPC calls (e.g. SOAP or basic XML-RPC).
  • Level 1 (Resources): Distinct URIs for individual resources (/orders/123), but uses single HTTP methods.
  • Level 2 (HTTP Verbs): Uses standard HTTP methods (GET, POST, PUT, DELETE) with meaningful HTTP status codes (200, 201, 404). Most production APIs operate here.
  • Level 3 (HATEOAS): Hypermedia As The Engine Of Application State—responses include dynamic links guiding the client on valid subsequent actions.

Interactive Quiz

Practice Quiz

Question 1
What does the "Statelessness" constraint require in a RESTful API architecture?
Question 2
Why are noun-based URIs (/api/v1/orders/) preferred over verb-based URIs (/api/v1/createOrder/) in REST?
Question 3
What is the highest level (Level 3) of the Richardson Maturity Model for REST APIs?
Question 4
How does the Client-Server Separation constraint benefit modern distributed applications?
Question 5
What is a major scalability benefit of statelessness when deploying backend services behind a load balancer?
Next Lesson

HTTP Methods Overview

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
NoneHTTP Methods Overview

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext