惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

M
MIT News - Artificial intelligence
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
博客园 - Franky
腾讯CDC
T
Tailwind CSS Blog
Recent Announcements
Recent Announcements
V
V2EX
N
Netflix TechBlog - Medium
量子位
Jina AI
Jina AI
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
爱范儿
爱范儿
博客园 - 叶小钗
D
Docker
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Rest & Restfulness API Design Principles
Rohit Sharma · 2026-06-18 · via DEV Community
Cover image for Rest & Restfulness API Design Principles

Rohit Sharma

Representational State Transfer is an architectural style used for designing the network applications. Instead of relying on complex protocols REST relies on standard web protocols like HTTP to enable communication between clients and server.

If Definition seems complex to you, no worries let's breakdown the word
REST = Representation State Transfer

Suppose you have a user resource:

/users/7

This actual resource, exists on the server.

REPRESENTATION The server doesn't send the actual database row. It sends a representation of the resource.

{
 "id":7,
 "name":"Rohit"
}

This JSON is a representation of the user's current state.

STATE TRANSFER When the client requests

GET users/7

The server transfers representation of this resource's state to the client.

   Server State
        ⬇️
JSON Representation
        ⬇️
Transferred over HTTP
        ⬇️
      Client

That's where the term Representational state transfer comes from.

Main Idea behind REST: It operates on stateless communication which means that each request from client contains all the necessary information and server does not store any session data between requests. This makes REST very scalable, reliable and easy to implement.

Why REST matters?

  1. Simplicity & Scalability: Rest is build on standard HTTP protocols like GET, PUT, POST and DELETE making it easy to understand and implement. Because REST follow stateless architecture it scales efficiently, allowing multiple servers to handle requests without maintaining session data.

  2. Interoperability: REST APIs are platform independent which means they can be consumed by clients running on different devices, different Operating Systems and implemented in different programming languages. Whether its a mobile application or web application, REST can be used everywhere.

  3. Efficiency: By leveraging caching REST can introduce lower latency which contribute towards enhancing performance.

app.get(/product/:id, async(req,res) =>{
  product = await productService.getProduct(req.params.id);
  res.set('Cache-Control', 'public, max-age=300');  //this tells clients, browsers, CDNs, reverse proxies & API Gateways: You may cache this response for 300 seconds
  res.json(product);
})

REST's cachebility constraint is typically implemented by sending HTTP cache headers such as Cache-Control, ETag or expires. These headers allow clients to cache responses, reducing the latency and backend loads.

RESTful API Design Principles

Not every API using HTTP is RESTful, A RESTful API is an API that follows REST principles correctly. So, below are the design principles of a perfect REST API:

1.Resource-Based URLs: Resources should be nouns, not verbs.

❌BAD

GET /getUsers
POST /createUser
DELETE /deleteUser/101

✅GOOD

GET /users
POST /users
DELETE /users/101

2.Use HTTP methods properly

GET    /users       -> Fetch users
POST   /users       -> Create user
PUT    /users/101   -> Replace user
PATCH  /users/101   -> Update user
DELETE /users/101   -> Delete user

3.Statelessness: Every request should contain all information needed. Server should not remember previous requests.

GET /orders
Authorization: Bearer JWT_TOKEN

//The JWT carries user identity. Server doesn't need session memory.

4.Client-Server Separation: Frontend and backend are independent. Frontend can change without changing backend
5.Cacheable Responses: Frequently accessed data can be cached, which eventually reduces latency and improves performance.

Example of perfect RESTful User API

GET    /users
GET    /users/101
POST   /users
PUT    /users/101
PATCH  /users/101
DELETE /users/101

This is considered RESTful because:

✅ Resources are nouns
✅ Correct HTTP methods used
✅ Stateless
✅ Consistent URL design