Return to site

🚦📡 LEVELS OF RESTFUL API (RICHARDSON MATURITY MODEL)

October 25, 2025

🔸 TL;DR

REST maturity grows from one RPC-style endpoint ➜ named resources ➜ proper HTTP methods & status codes ➜ hypermedia (HATEOAS) guiding clients with links. Aim for Level 2 as a solid baseline; use Level 3 when clients benefit from discoverability & workflow hints.

🔸 WHAT ARE THE LEVELS?

▪️ A simple ladder to structure your API design from ad-hoc to truly RESTful.

▪️ Helps teams align on resource modeling, HTTP semantics, and client guidance.

🔸 LEVEL 0 — “THE SWAMP OF POX” 🪵

▪️ One catch-all endpoint (e.g., POST /api) carrying actions in the body.

▪️ Treats HTTP as a tunnel; verbs/status codes are underused.

▪️ Fast to start, hard to evolve, poor caching/observability.

🔸 LEVEL 1 — RESOURCES 🗂️

▪️ Introduce nouns/URIs: /orders, /orders/{id}, /customers/{id}.

▪️ Still action-centric inside payloads, but resources are addressable.

▪️ Enables cleaner routing and simpler client code.

🔸 LEVEL 2 — HTTP VERBS & STATUS CODES ⚙️

▪️ Use the web’s contract: GET/POST/PUT/PATCH/DELETE on resources.

▪️ Meaningful status codes (200, 201, 204, 400, 404, 409, 429, 5xx).

▪️ Respect idempotency (PUT/DELETE) & partial updates (PATCH).

▪️ Embrace caching (ETag, Cache-Control) and content negotiation.

▪️ This level gives you most of REST’s benefits (scalability, clarity).

🔸 LEVEL 3 — HYPERMEDIA CONTROLS (HATEOAS) 🔗

▪️ Responses include links & actions so clients discover next steps:

{

"id": "123",

"status": "CREATED",

"_links": {

"self": {"href": "/orders/123"},

"pay": {"href": "/orders/123/payment", "method": "POST"},

"cancel":{"href": "/orders/123", "method": "DELETE"}

}

}

▪️ Improves discoverability, reduces tight coupling to out-of-band docs.

▪️ Great for workflows that evolve without breaking clients.

🔸 QUICK EXAMPLE ACROSS LEVELS 🧩

▪️ L0: POST /api {"action":"createOrder","data":{...}}

▪️ L1: POST /orders (resource exists, actions still in payload)

▪️ L2: POST /orders ➜ 201 + Location; GET /orders/{id}; PATCH /orders/{id}; proper codes & caching

▪️ L3: GET /orders/{id} returns _links for pay, cancel, track

🔸 TAKEAWAYS ✅

▪️ Model nouns first (resources), then apply HTTP semantics faithfully.

▪️ Level 2 is the pragmatic sweet spot for most teams.

▪️ Add HATEOAS when client flows change often or you need runtime guidance.

▪️ Don’t forget versioning, error formats (e.g., RFC 7807), and docs (OpenAPI).

#️⃣ s

#REST #API #HATEOAS #HTTP #Backend #SoftwareEngineering #WebArchitecture #OpenAPI #DeveloperExperience #Java #SpringBoot

Go further with Java certification:

Java👇

Spring👇