Script Valley
System Design: APIs, Caching & Scalability
API Design FundamentalsLesson 1.1

What is REST API and how does it work

REST constraints, statelessness, client-server model, uniform interface, HTTP verbs, resource naming

What is REST API and how does it work

REST API diagram

The Core Idea

REST (Representational State Transfer) is an architectural style, not a protocol. It defines six constraints that make distributed systems predictable and scalable. The most critical: statelessness. Every request must carry all the information needed to process it. The server stores no session state between requests.

HTTP Verbs Map to Actions

REST uses HTTP methods to express intent:

  • GET โ€” read a resource, safe and idempotent
  • POST โ€” create a new resource
  • PUT โ€” replace a resource entirely
  • PATCH โ€” partial update
  • DELETE โ€” remove a resource

Idempotency matters: calling DELETE /users/42 ten times has the same effect as calling it once. POST is not idempotent โ€” each call may create a new resource.

Resource Naming Rules

Use nouns, not verbs. Collections are plural:

# Good
GET  /articles
GET  /articles/99
POST /articles

# Bad
GET /getArticles
GET /fetchArticleById?id=99

Nest resources only one level deep. /users/5/orders is fine. /users/5/orders/3/items/7/reviews is a maintenance nightmare. Flat is better than deeply nested beyond two levels.

Up next

REST API versioning strategies explained

Sign in to track progress

What is REST API and how does it work โ€” API Design Fundamentals โ€” System Design: APIs, Caching & Scalability โ€” Script Valley โ€” Script Valley