DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
← From Beginner to Expert in Fundamentals of Frontend
  • How the Web Works
  • Browsers: The Engines
  • Networking & Latency
  • HTTPS & TLS Handshake
  • CDNs & Edge Computing
  • WebSockets & WebRTC
  • RESTful Architecture
  • GraphQL Architecture
  • CORS (Cross-Origin Resource Sharing)
  • Load Balancing
  • Critical Rendering Path Deep Dive
  • DOM vs. CSSOM Construction
  • The Rendering Engine: Layout, Paint, Compositing
  • JavaScript Engine: V8 Internals
  • The Event Loop: Macro vs. Micro Tasks
  • Garbage Collection
  • Browser Storage Architecture
  • Service Workers & PWAs
  • Web Workers: Multi-Threading
← From Beginner to Expert in Fundamentals of Frontend

RESTful Architecture

20 min read
RESTStatelessnessCRUDHTTP MethodsStatus CodesHATEOASAPI Design

REST: The Backbone of Web APIs

REST (Representational State Transfer) is an architectural style, not a protocol. It defines constraints that make APIs scalable, simple, and predictable.

The 6 REST Constraints

  1. Client-Server: Frontend and backend are separate, evolving independently.
  2. Stateless: Each request contains ALL information needed. The server stores no session state between requests.
  3. Cacheable: Responses must declare if they're cacheable to improve performance.
  4. Uniform Interface: Resources are identified by URIs. Representations (JSON/XML) are used to manipulate them.
  5. Layered System: Client can't tell if it's connected to the end server or a load balancer/CDN.
  6. Code on Demand (Optional): Servers can send executable code (JavaScript) to clients.

HTTP Methods & Their Semantics

MethodCRUDIdempotent?Safe?Example
GETReadYesYesGET /api/users/123
POSTCreateNoNoPOST /api/users
PUTReplaceYesNoPUT /api/users/123
PATCHPartial UpdateNo*NoPATCH /api/users/123
DELETEDeleteYesNoDELETE /api/users/123

Status Codes You Must Know

  • 200 OK — Success
  • 201 Created — Resource created (POST)
  • 204 No Content — Success with no body (DELETE)
  • 301 Moved Permanently — URL changed (SEO impact!)
  • 400 Bad Request — Client sent invalid data
  • 401 Unauthorized — Not authenticated
  • 403 Forbidden — Authenticated but not authorized
  • 404 Not Found
  • 429 Too Many Requests — Rate limited
  • 500 Internal Server Error
  • 503 Service Unavailable

Resource Naming Best Practices

  • Use nouns, not verbs: /api/users not /api/getUsers
  • Use plural: /api/users not /api/user
  • Use nesting for relationships: /api/users/123/orders
  • Use query params for filtering: /api/users?role=admin&sort=name

Idempotency Explained

An operation is idempotent if calling it multiple times produces the same result. GET, PUT, and DELETE are idempotent. POST is not — calling POST /users twice creates two users.

This matters for retry logic: if a network error occurs during a PUT request, you can safely retry. If it happens during POST, you might create duplicates.

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.