Module 04 / 20 · Phase A — Request & Response · finale · 40 min

REST APIs
from first principles.

You speak HTTP. Now let's see what happens when teams agree to use it consistently. REST isn't a technology — it's a discipline. Most "REST APIs" out there break the rules. Time to learn which ones matter, and design one yourself.

// What you'll know by the end

  • What REST actually is (and isn't)
  • Resources vs actions — the core mental flip
  • How HTTP methods map to CRUD operations
  • Design your own API in the lab
§ 01 — The opening flip

Most APIs are
doing it wrong.

Look at any API documentation in the wild and you'll see a war between two styles. On one side: action-based URLs — every operation gets its own URL with a verb in the path. On the other: resource-based URLs — the URL identifies a thing, and the HTTP method describes what to do with it. The second style is REST. Compare:

✗ ACTION-BASED (RPC-style)
Verbs everywhere
POST /getUsers
POST /getUserById
POST /createUser
POST /updateUser
POST /deleteUser
POST /getUserPosts
✓ RESOURCE-BASED (REST)
Nouns + methods
GET /users
GET /users/42
POST /users
PUT /users/42
DELETE /users/42
GET /users/42/posts

Same six operations, two completely different design philosophies. The left side invents a new endpoint for every action. The right side has just two URLs (/users and /users/42) — and uses HTTP's existing verbs to do all the work. That's the entire idea of REST in one screen. Everything else is just rules for keeping the discipline.

§ 02 — The core idea

Everything is a
resource.

REST stands for Representational State Transfer — a name that has scared off generations of developers. Ignore the name. Here's the actual idea:

Resources are nouns.
HTTP methods are verbs.
That's the rule.

Once you internalize this, every "should I name this endpoint /createUser or /users?" debate dissolves. The answer is always POST /users. The URL identifies the resource (the user collection); the method says what to do (create one). Designing an API becomes a question of "what are my resources?" instead of "what are all the actions my client needs to do?"

§ 03 — CRUD, expressed in HTTP

Five operations.
One pattern.

"CRUD" — Create, Read, Update, Delete — is the most common set of operations any system needs. REST maps these directly to HTTP methods, and the URL pattern is mechanical. Memorize this table; you'll see it everywhere.

Method
Operation
URL Pattern
What it means
GET
List all
/posts
Return every post. Often paginated (?page=2&limit=20). Read-only.
GET
Read one
/posts/42
Return the post with id 42, or 404 if it doesn't exist.
POST
Create
/posts
Create a new post from the JSON body. Server assigns the id. Returns 201 + Location header.
PUT
Replace
/posts/42
Replace post 42 entirely with the JSON body. Idempotent — repeat safely.
PATCH
Modify
/posts/42
Update just the fields you sent. { "title": "..." } only changes the title.
DEL
Remove
/posts/42
Delete post 42. Usually returns 204 No Content. Repeat = same (gone is gone).
GET
Nested list
/posts/42/comments
Comments belong to a post. Nesting expresses ownership. List all comments on post 42.
POST
Nested create
/posts/42/comments
Add a new comment to post 42. Same pattern, one level deeper.

That's it. Two URL patterns — collection (/posts) and item (/posts/42) — combined with five HTTP methods. From these primitives, you can express almost any CRUD-style operation in any system. The nesting (/posts/42/comments) is just the same pattern applied recursively.

§ 04 — REST Designer · interactive lab

Now design
a real API yourself.

You're building the backend for a small blog platform. For each operation below, pick the most RESTful URL design. You'll get instant feedback on every choice — and at the end, see the complete API you built.

REST_DESIGNER.SIM // m.04 lab
Progress: 1/6 Score: 0
TASK 1 / 6
Loading task...
Pick the most RESTful option

// YOUR API SO FAR

6 / 6

Clean & consistent.

Anyone reading this API can predict every endpoint.

§ 05 — Five rules that actually matter

REST is a discipline.
These are the rules.

The original REST paper has six "constraints." In practice, these five carry their weight every day. Internalize them and your APIs will be predictable, scalable, and pleasant to use.

i

Resources are nouns

Never put a verb in the URL. /users, not /getUsers. /orders/42/cancel is a yellow flag — could you model it as PATCH /orders/42 with {"status":"cancelled"} instead? Sometimes the verb is unavoidable, but the default should always be a noun.

ii

Stateless requests

Every request carries everything the server needs to handle it — auth, params, body. The server doesn't remember anything between requests. This is what lets you put a load balancer in front and have any server handle any request. We'll go deep in Module 13.

iii

Use status codes honestly

2xx for success, 4xx for client errors, 5xx for server errors. Don't return 200 with {"error": "..."} in the body. The status code IS the result. Lying about it breaks every monitoring tool, retry logic, and CDN policy that depends on HTTP working as advertised.

iv

Consistent naming

Pick a style and stick with it. Plural nouns (/users, not /user). Lowercase. Kebab-case for multi-word (/blog-posts). Whatever you choose, apply it everywhere. Inconsistency is more painful than the wrong choice.

v

Version your API

Once an API has clients, breaking it breaks them. Put a version in the URL (/v1/users) or in a header. When you need to break something, ship v2 and deprecate v1 gracefully. Without versioning, you can never evolve safely.

vi

Honorable mention: HATEOAS

The original REST paper says responses should include links to related resources ("here's the user, and here's the URL for their posts"). In practice, almost no APIs do this. Know it exists, know what it means, then carry on without losing sleep.

These rules aren't laws — they're conventions that make APIs predictable. Predictability is the entire point. When someone reads GET /orders/42/items, they should be able to guess that POST /orders/42/items creates a new item and DELETE /orders/42/items/7 removes one. That guessability is REST's real superpower.

§ 06 — Eight words for API design

Vocabulary,
for the spec.

You'll hear these in every API design review for the rest of your career. Learn them well enough that you can challenge people who misuse them.

Resource
/ˈriːsɔːs/
A thing your API manages. users, posts, orders. Each resource gets a URL. Always a noun.
Collection
/kəˈlɛkʃən/
A list of resources. /posts is a collection. /posts/42 is one item. GET on a collection returns the list; POST creates a new item.
Endpoint
/ˈɛndpɔɪnt/
One specific URL + method combo. GET /users/42 is an endpoint. DELETE /users/42 is a different endpoint.
Representation
/ˌrɛprɪzɛnˈteɪʃən/
The format the resource is returned in — typically JSON. The "RE" in "REST". Same resource can have multiple representations (JSON, XML, HTML).
CRUD
/krʌd/
Create, Read, Update, Delete. The four basic operations on any resource. REST maps them onto POST, GET, PUT/PATCH, and DELETE.
Pagination
/ˌpædʒɪˈneɪʃən/
Returning a list in chunks rather than all at once. Usually via ?page=2&limit=20 or cursor-based. Never return an unbounded list — that's an outage waiting to happen.
Versioning
/ˈvɜːʃənɪŋ/
Marking which version of the API a client is talking to. Usually /v1/... in the path. Lets you ship breaking changes without breaking existing clients.
HATEOAS
/ˈheɪ.tiː.oʊ.æs/
"Hypermedia As The Engine Of Application State." Responses should link to related resources. The purist REST ideal that nobody actually implements.
§ 07 — Knowledge check

Five questions.
Defend the discipline.

You've designed an API. Now lock in the principles behind it.

QUESTION 1 OF 5
Loading question...
Score: 0 / 5
5 / 5

Architect.

Phase A is officially yours. Time to look under the hood at data.

§ 08 — The recap

Three ideas to
carry forward.

You've completed Phase A. Carry these into everything that follows.

i

Resources, not actions

URLs identify things; HTTP methods describe what to do with them. POST /users, not /createUser. This single flip cleans up most API design debates.

ii

CRUD has a canonical map

List = GET collection. Read = GET item. Create = POST collection. Replace = PUT item. Modify = PATCH item. Delete = DELETE item. Memorize.

iii

Predictability is the point

If a developer can guess your endpoints without reading the docs, you've succeeded. Consistency, honest status codes, and stateless requests are how you get there.

PHASE A COMPLETE Request & Response · 4 modules · Up next: Phase B — Data & Storage
↓ UP NEXT · PHASE B BEGINS

M.05 — SQL vs NoSQL,
without the hype.

You can move data around the internet. Now we look at where it actually lives. The world has two big families of databases — relational and not — and every team eventually has to choose. Time to know what you're picking between.

Continue to Module 05 →