REST Principles: Resources, Statelessness, and Maturity
Learn the REST constraints, resource modeling, statelessness, HATEOAS, and the Richardson Maturity Model
Greetings, brave adventurer! You have learned to speak HTTP in the API Fundamentals quest. Now you will learn to speak it well. REST - Representational State Transfer - is the architectural style that turns raw HTTP requests into elegant, predictable APIs that millions of developers can use without reading a manual.
This quest teaches you the constraints Roy Fielding described in his year-2000 doctoral dissertation, how to model your domain as resources, why statelessness is a superpower at scale, and how to honestly assess where any API sits on the path to true REST.
📖 The Legend Behind This Quest
In the year 2000, an architect named Roy Fielding wrote down the principles that already made the web work and gave them a name: REST. He did not invent a technology - he described the constraints that, when honored, give a distributed system its remarkable properties: it scales, it tolerates failure, its parts evolve independently, and a newcomer can guess how it works.
Most APIs that call themselves “RESTful” only follow some of these constraints. Understanding the full model lets you make deliberate trade-offs instead of accidental ones - and recognize when “REST” is just a buzzword on someone’s slide deck.
🎯 Quest Objectives
By the time you complete this journey, you will have mastered:
Primary Objectives (Required for Quest Completion)
- The REST Constraints - Name and explain the six architectural constraints
- Resources and Representations - Model a domain as nouns addressable by URL
- Statelessness - Explain why each request must carry everything it needs
- The Uniform Interface - Use HTTP methods and status codes consistently
- The Richardson Maturity Model - Place any API on the 0-3 maturity scale
Secondary Objectives (Bonus Achievements)
- HATEOAS - Understand hypermedia controls and why few APIs reach Level 3
- Resource Relationships - Model nested and linked resources cleanly
- Idempotency and Safety - Apply method semantics correctly in a real design
Mastery Indicators
You’ll know you’ve truly mastered this quest when you can:
- Design resource URLs for a new domain without hesitation
- Explain to a teammate why storing session state in the server breaks REST
- Score any public API on the Richardson Maturity Model
- Argue both for and against HATEOAS for a given project
🗺️ Quest Prerequisites
📋 Knowledge Requirements
- You have completed API Fundamentals or know HTTP methods and status codes
- You can make and read requests with curl
- You understand JSON
🛠️ System Requirements
- Modern operating system (Windows 10+, macOS 10.14+, or Linux)
curlavailable in your terminal- Optional:
jqfor inspecting JSON responses - An internet connection
🧠 Skill Level Indicators
This 🟡 Medium quest expects:
- You can already call an API and read its response
- You are ready to reason about design trade-offs
- Ready for 75-90 minutes of focused learning
🌍 Choose Your Adventure Platform
REST is an architectural style, not a tool - it runs everywhere HTTP does. Use these commands to explore a real REST API while you read.
🍎 macOS Kingdom Path
Click to expand macOS instructions
```bash # Explore GitHub's REST API - a famously well-designed example brew install jq curl -s https://api.github.com/repos/torvalds/linux | jq '{name, stargazers_count}' ```🪟 Windows Empire Path
Click to expand Windows instructions
```powershell # Explore a real REST API from PowerShell winget install jqlang.jq curl.exe -s https://api.github.com/repos/torvalds/linux | jq "{name, stargazers_count}" ```🐧 Linux Territory Path
Click to expand Linux instructions
```bash sudo apt update && sudo apt install -y curl jq # Debian/Ubuntu # Explore the resource-oriented structure of a real API curl -s https://api.github.com/repos/torvalds/linux | jq '{name, stargazers_count}' ```☁️ Cloud Realms Path
Click to expand Cloud/Container instructions
```bash # Any container with curl works the same way docker run --rm curlimages/curl:latest -s \ https://api.github.com/repos/torvalds/linux ```🧙♂️ Chapter 1: The Six REST Constraints
REST is defined by constraints, not features. An API is “RESTful” to the degree it honors these six.
⚔️ Skills You’ll Forge in This Chapter
- The six constraints and what each buys you
- Why constraints, not freedoms, create good architecture
🏗️ The Constraints
- Client-Server - separate the user interface from data storage so each evolves independently.
- Stateless - every request contains all the information needed to process it; the server stores no client session between requests.
- Cacheable - responses must declare whether they can be cached, so clients and intermediaries can reuse them.
- Uniform Interface - the heart of REST: resources are identified by URLs, manipulated through representations, messages are self-descriptive, and hypermedia drives state (HATEOAS).
- Layered System - a client cannot tell whether it is connected directly to the server or through proxies, gateways, and load balancers.
- Code on Demand (optional) - servers may extend clients by sending executable code (e.g., JavaScript).
The uniform interface is what makes REST feel familiar across APIs: a GET always reads, a 404 always means “not found,” and a resource always lives at a URL.
🔍 Knowledge Check: Constraints
- Which constraint lets you add a load balancer without clients noticing?
- Which constraint is the only optional one?
- What does the “uniform interface” guarantee a newcomer?
⚡ Quick Wins and Checkpoints
- Named all six: You can list the constraints from memory
- Spotted layering: You explained why a client need not know about proxies
🧙♂️ Chapter 2: Resources, URLs, and Statelessness
In REST, everything is a resource: a user, an order, a comment. A resource is identified by a URL, and you exchange representations of it (usually JSON). Good URL design is mostly about choosing the right nouns.
⚔️ Skills You’ll Forge in This Chapter
- Designing resource-oriented URLs
- Modeling collections, items, and relationships
- Why statelessness scales
🏗️ Resource-Oriented URL Design
URLs name nouns; HTTP methods supply the verbs. Avoid verbs in your paths.
✅ Resource-oriented (good) ❌ RPC-style (avoid)
GET /users GET /getAllUsers
GET /users/42 GET /getUserById?id=42
POST /users POST /createUser
PUT /users/42 POST /updateUser
DELETE /users/42 POST /deleteUser
GET /users/42/orders GET /getOrdersForUser?id=42
Collections are plural (/users); a single item lives under its id (/users/42); relationships nest (/users/42/orders). Filtering, sorting, and paging belong in the query string, not the path:
# Filtering and paging via query parameters, not new endpoints
curl -s "https://jsonplaceholder.typicode.com/comments?postId=1&_limit=3" | jq 'length'
Statelessness means the server keeps no per-client memory between requests. Each request re-sends whatever the server needs - typically an auth token in a header. The payoff is enormous: any server in a fleet can handle any request, so you scale horizontally just by adding machines, and a crash loses no session.
GET /account HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGciOi...
🔍 Knowledge Check: Resources
- Rewrite
GET /getOrdersForUser?id=42as a resource-oriented URL - Where do filtering and paging parameters belong?
- Why does statelessness make horizontal scaling easy?
🧙♂️ Chapter 3: HATEOAS and the Richardson Maturity Model
Leonard Richardson described a four-level ladder that measures how RESTful an API really is. Climbing it clarifies exactly which constraints an API honors.
⚔️ Skills You’ll Forge in This Chapter
- The four levels of REST maturity
- What HATEOAS adds and why it is rare
- Scoring real APIs
🏗️ The Richardson Maturity Model
| Level | Name | What it means |
|---|---|---|
| 0 | The Swamp of POX | One URL, one method (usually POST). HTTP is just a tunnel. |
| 1 | Resources | Many URLs, one resource each, but still one method. |
| 2 | HTTP Verbs | Proper use of GET/POST/PUT/DELETE and meaningful status codes. Most “REST” APIs live here. |
| 3 | Hypermedia Controls (HATEOAS) | Responses include links telling the client what it can do next. |
HATEOAS (Hypermedia As The Engine Of Application State) means the server returns not just data but the links to related actions, so the client discovers the API by following links rather than hard-coding URLs:
{
"id": 42,
"status": "pending",
"total": 79.99,
"_links": {
"self": { "href": "/orders/42" },
"cancel": { "href": "/orders/42/cancel", "method": "POST" },
"pay": { "href": "/orders/42/payment", "method": "POST" }
}
}
A Level 3 client never builds the URL /orders/42/cancel itself - it reads the cancel link from the response. This decouples clients from URL structure, so the server can change paths freely. In practice few APIs reach Level 3 because it adds complexity and most clients are written against fixed docs anyway. Level 2, done well, is the pragmatic sweet spot.
Inspect how GitHub’s API embeds related resource URLs (a hypermedia trait):
# GitHub responses embed related resource URLs ending in _url
curl -s https://api.github.com/repos/torvalds/linux | jq 'keys | map(select(test("_url$"))) | length'
🔍 Knowledge Check: Maturity
- At which level do most “RESTful” APIs actually sit?
- What single feature distinguishes Level 3 from Level 2?
- Give one reason teams skip HATEOAS.
🎮 Mastery Challenges
🟢 Novice Challenge: Fix the URLs
Objective: Convert an RPC-style API to resource-oriented URLs.
Requirements:
- Rewrite
getProduct,createProduct,deleteProduct,listProductsForCategory - Use the correct HTTP method for each
- Put any filtering in the query string
Validation: No verbs appear in your paths.
🟡 Intermediate Challenge: Model a Domain
Objective: Design the resources for a simple blog (posts, comments, authors).
Requirements:
- Define collection and item URLs for each resource
- Model the post-to-comments relationship with nesting
- Assign a success status code to each operation
Validation: A stranger could guess your URLs from the resource names.
🔴 Advanced Challenge: Score Three APIs
Objective: Assess three public APIs on the Richardson Maturity Model.
Requirements:
- Pick three APIs (e.g., GitHub, JSONPlaceholder, a SOAP service)
- Assign each a level 0-3 with justification
- Identify what each would need to climb one level
Validation: Each score is defensible from the API’s actual behavior.
🏆 Quest Rewards & Achievements
🎖️ Badges Earned:
- 🏆 Architect of Interfaces - You designed a clean, resource-oriented API
- 🧭 Keeper of Constraints - You internalized the six REST constraints
🛠️ Skills Unlocked:
- Resource Modeling - Turn a domain into addressable resources
- REST Maturity Assessment - Place any API on the maturity ladder
🔓 Unlocked Quests:
- API Versioning - Evolve a REST API without breaking clients
- API Documentation - Describe your resources with OpenAPI
📊 Progression Points: +60 XP
🗺️ Next Steps in Your Journey
Continue the Main Story:
- 🎯 API Versioning - Evolve without breaking clients
Explore Side Adventures:
- ⚔️ API Documentation - Describe your API with OpenAPI
- ⚔️ Error Handling - Consistent, helpful errors
Character Class Recommendations
💻 Software Developer: Continue to API Versioning
🏗️ System Engineer: Explore API Documentation
🛡️ Security Specialist: Check out API Authentication
📚 Resources
Official Documentation
- Roy Fielding’s REST dissertation, Chapter 5 - The original source
- MDN: HTTP overview - HTTP foundations REST builds on
- GitHub REST API docs - A reference-quality REST API
Community Resources
- Martin Fowler: Richardson Maturity Model - The classic explanation
- Microsoft REST API Guidelines - Production design conventions
- JSONPlaceholder - A practice REST API
Learning Materials
- REST API Tutorial - Constraints and best practices
- Google API Design Guide - Resource-oriented design at scale
- HATEOAS (MDN glossary) - The hypermedia constraint
🤝 Quest Completion Checklist
- ✅ Completed all primary objectives
- ✅ Designed a resource model for a small domain
- ✅ Answered all knowledge check questions
- ✅ Completed at least one mastery challenge
- ✅ Explored the resource library
- ✅ Identified your next quest in the journey
🕸️ Knowledge Graph
Structured wiki-links connect this quest to the IT-Journey knowledge graph. Open the Obsidian Graph View to explore connections.
Level hub: [[Level 0111 - API Development]] Overworld: [[🏰 Overworld - Master Quest Map]] Prerequisites: [[API Fundamentals: HTTP, Requests, and JSON]] Unlocks: [[API Versioning: URI, Headers, and Backward Compatibility]] · [[API Documentation: OpenAPI, Swagger, and Contract-First]] Obsidian docs: [[Obsidian Knowledge Graph and Wiki Links]]
🎁 Rewards
Badges
- 🏆 Architect of Interfaces - Designed a clean, resource-oriented API
- 🧭 Keeper of Constraints - Internalized the six REST constraints
Skills unlocked
- 🛠️ Resource Modeling
- 🧠 REST Maturity Assessment
Features unlocked
- Access to the API Versioning and API Documentation quests
🕸️ Quest Network
Referenced by
- Loading…