REST API design
Resource modeling, idempotency (PUT vs POST, idempotency keys), pagination (cursor vs offset), versioning, consistent error envelopes.
The mental model
A REST API is a contract, not a codebase. The moment you publish an endpoint, its shape — the URLs, the status codes, the error format, the pagination scheme — becomes a promise other people build against, often people you will never meet. Good API design is therefore mostly about making that contract obvious, stable, and hard to misuse, so a frontend engineer can build against it without a meeting and an external developer can integrate from the docs alone.
The mental model that organises the whole topic: **model resources (nouns), use HTTP's verbs and status codes for what they mean, and be relentlessly consistent.** REST is not "JSON over HTTP" — it is treating the API as a set of *resources* (a user, an order, an invoice) that you address by URL and act on with the standard verbs. GET /orders/42 reads order 42; DELETE /orders/42 removes it; you do not invent POST /getOrder or POST /deleteOrderNow. The HTTP method carries meaning — safety and idempotency — and the status code carries the outcome. When you honour those meanings, caches, proxies, retries, and every HTTP client in the world already know how to behave. When you fight them (200 with {"error": true} in the body, GET that mutates), you break every layer that trusts the protocol.
The analogy: HTTP is a **shared vocabulary** the entire web already speaks — verbs, status codes, headers, caching semantics. A well-designed REST API speaks that vocabulary fluently, so tools understand it for free: a CDN caches a GET, a client retries a failed PUT safely, a well-behaved API client or SDK honours a 429 Retry-After. A badly designed one invents its own dialect, and now every consumer needs a phrasebook (your docs) for things the protocol already standardised. The single most common cause of "the API is broken" is a consumer and a producer disagreeing about a detail the contract left ambiguous.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision