HTTP & APIs
REST
REST is an API design style that uses standard HTTP verbs and clean, resource-based URLs to organize and edit data.
Diagram
RESTful API Design Pattern: Resource: Users ────────────────────────────────────────── GET /api/v1/users → list all POST /api/v1/users → create one GET /api/v1/users/:id → get one PUT /api/v1/users/:id → replace one PATCH /api/v1/users/:id → update fields DELETE /api/v1/users/:id → delete one ──────────────────────────────────────────
In Depth
REST (Representational State Transfer) is an architectural style for designing APIs. It is a set of design conventions for exposing database models over HTTP so that client apps can perform CRUD operations on them.
Code Example
Standard REST CRUD route pattern
GET /api/v1/posts → 200 { posts: [...] }
POST /api/v1/posts → 201 { id: "p_91", title: "..." }
PATCH /api/v1/posts/p_91 → 200 { updated fields }
DELETE /api/v1/posts/p_91 → 200 { deleted: true }⚠️ Common Misconception
REST is not a protocol or a library. It is simply a style guide. A system does not crash if it violates REST constraints, but it will be harder to maintain and scale.
🌍 Real World Usage
Most web platforms (GitHub, Stripe, Shopify, Twitter) expose REST APIs. Developers use tools like `fetch` or `Axios` to make calls to these routes.