REST API Design — Fundamentals
Resources as nouns, not verbs — the classic `/getUsers` mistake
The single most common beginner mistake in API design is putting the action in the URL: /getUsers, /createUser, /deleteUser?id=42. This duplicates information the HTTP method already carries and produces an inconsistent, ever-growing list of ad-hoc endpoint names. The fix: the URL names a resource (a noun — /users), and the HTTP method supplies the action (a verb):
Once you commit to nouns-in-URLs, an API's shape becomes self-documenting — a developer can guess PATCH /users/42 updates user 42 without reading a single line of docs, because the convention is doing the explaining.
The core HTTP methods and their semantics
Each method carries a specific, well-understood meaning — using the "wrong" one for an operation (e.g. GET to delete something) breaks assumptions clients, proxies, and caches all rely on.
Status code categories — what each range promises
A status code is the first thing client code checks, before it even looks at the body. Getting the range right is what lets a client's generic "did this succeed?" logic work correctly across the entire API, not just one endpoint.
A client library's default retry logic often keys off exactly this: retry automatically on most 5xx (transient server failure), never automatically retry on 4xx (the request itself needs to change, retrying identically won't help).
Nesting resources in URLs — expressing relationships
When a resource genuinely belongs to a parent, nesting the URL expresses that relationship directly:
Nesting more than 2-3 levels deep (/users/42/orders/991/items/3/reviews) usually signals it's time to give the deeply-nested resource its own top-level, filterable endpoint instead (GET /reviews?item_id=3) — deep nesting makes URLs harder to construct correctly and doesn't scale well as relationships grow.
Request/response body shape — JSON as the default contract
Most modern REST APIs use JSON for both request and response bodies. The body's shape is itself part of the API's design surface — consistent field naming (snake_case or camelCase, pick one and never mix), consistent date formats (ISO 8601 — "2026-09-01T14:30:00Z"), and consistent nesting conventions all reduce the amount a client has to guess.
Headers' role — metadata that travels alongside the body
Headers carry information that isn't the data itself but affects how it's interpreted or handled:
Content-Type and Authorization are the two you'll see constantly: Content-Type on both requests (what you're sending) and responses (what you're getting back); Authorization on requests that require identifying who's calling. This platform's later Authentication technology covers Authorization header mechanics (tokens, sessions) in implementation depth — here, the point is just that authentication and authorization are conveyed via headers, not embedded in the URL or body.
Try It (2 Minutes)
Design (on paper, no server needed) the URL + method + expected success status code for: "a client wants to mark comment 55 on post 12 as resolved, without changing anything else about the comment." (One reasonable answer: PATCH /posts/12/comments/55 with body {"resolved": true}, status 200 OK — PATCH because it's a partial update, not a full replace.)

