What is REST API? 9 Powerful Concepts Beginners Must Know
When you open a weather app and it shows today’s forecast — that data came from somewhere. When you pay through a mobile app — your bank was contacted somehow. When you log in with Google on a third-party website — Google was asked to verify your identity.
In every one of these cases, applications are talking to each other. And the language they most commonly use to have that conversation is a REST API.
So, what is REST API exactly? It is the most widely used standard for building web services in the world. Understanding it is not optional for anyone building modern web or mobile applications — it is fundamental.
In this beginner-friendly guide, we break down what is REST API across 9 powerful concepts — with real request and response examples, best practices, and practical guidance for building and consuming APIs.
Let’s go. 🚀
What is REST API? (Simple Definition)
What is REST API? REST stands for Representational State Transfer. A REST API (also called a RESTful API) is an architectural style for building web services that allows different software applications to communicate with each other over HTTP — the same protocol used by web browsers.
Breaking that definition down:
- REST — A set of architectural constraints and principles first defined by Roy Fielding in his 2000 doctoral dissertation
- API — Application Programming Interface — a way for applications to expose their functionality to other applications
- REST API — An API that follows REST principles, using HTTP as its communication protocol
What is REST API doing in simple terms?
A REST API exposes your application’s data and functionality as resources accessible via URLs. Other applications make HTTP requests to those URLs and receive responses — typically in JSON format.
Client Application Server (REST API)
│ │
│── GET /api/users/123 ──────────────→ │
│ │ (Find user 123 in database)
│ ←── 200 OK + { user data in JSON } ───│
│ │
│── POST /api/users ──────────────────→ │
│ { name: "Rahul", email: "..." } │ (Create new user)
│ │
│ ←── 201 Created + { new user } ───────│
What is REST API used for?
- Mobile apps fetching data from a backend server
- Frontend JavaScript apps communicating with backend services
- Third-party integrations (payment gateways, maps, weather)
- Microservices communicating with each other
- IoT devices sending and receiving data
💡 Simple Analogy: What is REST API like in everyday terms? Think of a restaurant. You (the client) do not go into the kitchen (the server) directly. Instead, you use the menu (API documentation) to place an order (HTTP request) with the waiter (API endpoint). The kitchen prepares your food and the waiter brings it back (HTTP response). REST API is the standardized system that makes this exchange possible between software applications.
A Brief History of REST API
Understanding what is REST API includes knowing its origin:
- 2000 — Roy Fielding published his doctoral dissertation defining REST architectural principles at UC Irvine
- 2000s — REST emerged as an alternative to the complex SOAP (Simple Object Access Protocol) XML-based web services
- 2006 — Amazon, Flickr, and del.icio.us adopted REST APIs — early adopters proved the model at scale
- 2008 — Twitter launched its REST API — developers could build apps on top of Twitter data
- 2010 — REST APIs became the dominant web service architecture, overtaking SOAP
- 2013 — JSON became the universal REST API response format, replacing XML
- 2015 — OpenAPI Specification (Swagger) standardized REST API documentation
- 2016 — GraphQL launched by Facebook as an alternative to REST for complex data needs
- 2026 — REST APIs remain the most widely used web service architecture globally, serving billions of requests daily
9 Powerful Concepts of REST API
Concept 1: REST Principles — The Six Constraints 📋
What is REST API built on? Six architectural constraints defined by Roy Fielding. A truly RESTful API follows all six.
1. Client-Server Architecture The client (frontend, mobile app) and server (backend API) are completely separate. They communicate only through the API interface. This separation allows them to evolve independently.
2. Statelessness Each request from client to server must contain all information needed to understand and process the request. The server stores no client session state between requests.
Request 1: GET /api/orders (no authentication)
→ 401 Unauthorized
Request 2: GET /api/orders
Headers: Authorization: Bearer eyJhbGc...
→ 200 OK (token contains all identity info needed)
The server does not "remember" Request 1 when processing Request 2
3. Cacheability Responses must define whether they are cacheable. Clients and intermediaries can cache cacheable responses to improve performance.
HTTP/1.1 200 OK
Cache-Control: max-age=3600 ← Cache this response for 1 hour
Content-Type: application/json
4. Uniform Interface All REST APIs follow the same interface conventions — using HTTP methods, standard status codes, and resource-based URLs. This makes any REST API immediately familiar to developers.
5. Layered System A client cannot tell whether it is connected directly to the server or through intermediaries (load balancers, caches, gateways). Each layer only knows about the layer immediately adjacent to it.
6. Code on Demand (Optional) Servers can send executable code to clients (like JavaScript). The only optional constraint.
Concept 2: Resources and URLs — How REST Thinks About Data 🗂️
What is REST API resource? In REST, everything is a resource — a noun that represents a piece of data or business entity. Resources are identified by URLs.
REST API URL design principles:
✅ GOOD — Noun-based, hierarchical, clear
GET /api/users → Get all users
GET /api/users/123 → Get user with ID 123
POST /api/users → Create a new user
PUT /api/users/123 → Update user 123 (full update)
PATCH /api/users/123 → Update user 123 (partial update)
DELETE /api/users/123 → Delete user 123
GET /api/users/123/orders → Get all orders for user 123
GET /api/users/123/orders/456 → Get order 456 of user 123
POST /api/users/123/orders → Create an order for user 123
❌ BAD — Verb-based, not RESTful
GET /api/getUser/123
POST /api/createUser
GET /api/deleteUser/123
POST /api/getUserOrders
What is REST API URL best practices:
✅ Use nouns, not verbs /api/articles not /api/getArticles
✅ Use plural nouns /api/users not /api/user
✅ Use lowercase with hyphens /api/blog-posts not /api/blogPosts
✅ Use hierarchy /api/users/123/posts not /api/user-posts/123
✅ Keep it intuitive URL should be self-explanatory
✅ Version your API /api/v1/users
Concept 3: HTTP Methods — The Verbs of REST API 🔧
What is REST API’s way of expressing actions? HTTP methods — the verbs that define what operation is being performed on a resource.
The five main HTTP methods:
GET — Read data (safe, idempotent):
http
GET /api/articles HTTP/1.1
Response:
HTTP/1.1 200 OK
{
"data": [
{ "id": 1, "title": "What is REST API?", "author": "Rahul" },
{ "id": 2, "title": "What is Docker?", "author": "Priya" }
],
"total": 2,
"page": 1
}
POST — Create new data:
http
POST /api/articles HTTP/1.1
{
"title": "What is REST API?",
"content": "A REST API is...",
"tags": ["api", "backend"]
}
Response:
HTTP/1.1 201 Created
{
"id": 123,
"title": "What is REST API?",
"content": "A REST API is...",
"createdAt": "2026-01-15T10:30:00Z"
}
PUT — Replace a resource completely:
http
PUT /api/articles/123 HTTP/1.1
{
"title": "What is REST API? Complete Guide",
"content": "Updated content...",
"tags": ["api", "backend", "tutorial"]
}
Response: 200 OK (entire resource replaced)
PATCH — Partially update a resource:
http
PATCH /api/articles/123 HTTP/1.1
{
"title": "What is REST API? Updated Title"
}
Response: 200 OK (only title changed — other fields untouched)
DELETE — Remove a resource:
http
DELETE /api/articles/123 HTTP/1.1
HTTP method properties:
| Method |
Safe |
Idempotent |
Has Body |
| GET |
✅ |
✅ |
No |
| POST |
❌ |
❌ |
Yes |
| PUT |
❌ |
✅ |
Yes |
| PATCH |
❌ |
❌ |
Yes |
| DELETE |
❌ |
✅ |
No |
Safe = Does not modify data. Idempotent = Same result no matter how many times repeated.
Concept 4: HTTP Status Codes — Communicating Results 📊
What is REST API status code? A three-digit number in every HTTP response that tells the client what happened with their request. Learning status codes is essential to understanding what is REST API communication.
Status code categories:
1xx — Informational (rarely seen directly)
2xx — Success (request worked)
3xx — Redirection (go somewhere else)
4xx — Client Error (you made a mistake)
5xx — Server Error (we made a mistake)
Most important status codes:
200 OK → Request succeeded. Response body contains result.
201 Created → Resource created successfully (after POST).
204 No Content → Success but no response body (after DELETE).
206 Partial Content → Partial data returned (pagination, range requests).
301 Moved Permanently → Resource moved to new URL permanently.
304 Not Modified → Cached version is still valid, use it.
400 Bad Request → Request malformed or invalid data sent.
401 Unauthorized → Not authenticated (no or invalid token).
403 Forbidden → Authenticated but not authorized for this action.
404 Not Found → Resource does not exist.
405 Method Not Allowed → HTTP method not supported for this endpoint.
409 Conflict → Request conflicts with current state (duplicate).
422 Unprocessable → Validation failed (correct format, wrong values).
429 Too Many Requests → Rate limit exceeded.
500 Internal Server Error → Something went wrong on the server.
502 Bad Gateway → Upstream server returned invalid response.
503 Service Unavailable → Server temporarily down or overloaded.
What is REST API status code best practice?
javascript
// Node.js Express — using correct status codes
app.post("/api/users", async (req, res) => {
const { name, email } = req.body;
// Validation failed
if (!name || !email) {
return res.status(400).json({
error: "Bad Request",
message: "name and email are required"
});
}
// Check for duplicate
const existing = await User.findOne({ email });
if (existing) {
return res.status(409).json({
error: "Conflict",
message: "A user with this email already exists"
});
}
const user = await User.create({ name, email });
return res.status(201).json({ data: user }); // 201 for creation
});
Concept 5: Request and Response Structure — The JSON Standard 📨
What is REST API data format? While REST allows any format, JSON (JavaScript Object Notation) has become the universal standard for REST API request and response bodies.
Standard REST API request structure:
http
POST /api/v1/orders HTTP/1.1
{
"userId": 456,
"items": [
{ "productId": 101, "quantity": 2 },
{ "productId": 205, "quantity": 1 }
],
"deliveryAddress": {
"street": "123 MG Road",
"city": "Bengaluru",
"pincode": "560001"
}
}
Standard REST API response structure:
json
HTTP/1.1 201 Created
Content-Type: application/json
X-Request-ID: abc-123-def
{
"success": true,
"data": {
"orderId": "ORD-2026-78901",
"userId": 456,
"status": "confirmed",
"items": [
{ "productId": 101, "name": "Laptop", "quantity": 2, "price": 75000 },
{ "productId": 205, "name": "Mouse", "quantity": 1, "price": 1200 }
],
"totalAmount": 151200,
"estimatedDelivery": "2026-01-18T10:00:00Z",
"createdAt": "2026-01-15T10:30:00Z"
}
}
Error response structure — be consistent:
json
HTTP/1.1 422 Unprocessable Entity
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"details": [
{
"field": "email",
"message": "Must be a valid email address"
},
{
"field": "items",
"message": "Cannot be empty"
}
]
}
}
What is REST API pagination structure:
json
{
"data": [...],
"pagination": {
"page": 1,
"limit": 20,
"total": 147,
"totalPages": 8,
"hasNext": true,
"hasPrev": false
},
"links": {
"self": "/api/articles?page=1&limit=20",
"next": "/api/articles?page=2&limit=20",
"last": "/api/articles?page=8&limit=20"
}
}
Concept 6: REST API Authentication — Securing Your Endpoints 🔐
What is REST API authentication? The mechanism for verifying the identity of clients making requests and ensuring they are authorized to access specific resources.
Most common REST API authentication methods:
1. Bearer Token (JWT) — Most widely used:
http
GET /api/profile HTTP/1.1
javascript
// Node.js Express middleware to verify JWT
const jwt = require("jsonwebtoken");
const authenticate = (req, res, next) => {
const authHeader = req.headers.authorization;
if (!authHeader || !authHeader.startsWith("Bearer ")) {
return res.status(401).json({ error: "Authentication required" });
}
const token = authHeader.split(" ")[1];
try {
const decoded = jwt.verify(token, process.env.JWT_SECRET);
req.user = decoded;
next();
} catch (err) {
return res.status(401).json({ error: "Invalid or expired token" });
}
};
// Protect routes
app.get("/api/profile", authenticate, (req, res) => {
res.json({ user: req.user });
});
2. API Key — For service-to-service:
3. OAuth 2.0 — For third-party access: Used when you want to let users log in with Google, GitHub, Facebook, etc.
4. Basic Authentication — Simple but not recommended for production:
Concept 7: REST API Versioning — Evolving Without Breaking 🔄
What is REST API versioning? The practice of maintaining multiple versions of your API simultaneously so existing clients are not broken when you make changes.
Why versioning is essential:
V1 API response: { "name": "Rahul Sharma" }
You change to: { "firstName": "Rahul", "lastName": "Sharma" }
Without versioning → All existing apps using "name" field break immediately
With versioning → V1 stays the same, V2 has the new structure
Versioning strategies:
URL versioning (most common and recommended):
/api/v1/users ← Version 1 (original)
/api/v2/users ← Version 2 (new structure)
Header versioning:
Query parameter versioning:
What is REST API versioning best practice in Node.js Express:
javascript
const express = require("express");
const app = express();
// V1 routes
const v1Router = express.Router();
v1Router.get("/users/:id", (req, res) => {
res.json({ name: "Rahul Sharma" }); // Old format
});
// V2 routes
const v2Router = express.Router();
v2Router.get("/users/:id", (req, res) => {
res.json({ // New format
firstName: "Rahul",
lastName: "Sharma"
});
});
app.use("/api/v1", v1Router);
app.use("/api/v2", v2Router);
Deprecation — communicating version end-of-life:
http
HTTP/1.1 200 OK
{"name": "Rahul"}
Concept 8: REST API Best Practices — Building Like a Pro 🏆
What is REST API design doing right when following best practices? Producing APIs that are intuitive, consistent, performant, and developer-friendly.
Use consistent naming conventions:
✅ GET /api/v1/blog-posts (hyphen-separated)
✅ GET /api/v1/blog-posts/123
✅ GET /api/v1/blog-posts?page=1&limit=20
❌ GET /api/v1/blogPosts (camelCase in URL)
❌ GET /api/v1/Blog_Posts (mixed case and underscore)
❌ GET /api/v1/getBlogPosts (verb in URL)
Filter, sort, and paginate properly:
GET /api/articles?status=published → Filter by status
GET /api/articles?tags=api,backend → Filter by multiple tags
GET /api/articles?sort=createdAt&order=desc → Sort
GET /api/articles?page=2&limit=20 → Paginate
GET /api/articles?fields=id,title,author → Sparse fieldsets
GET /api/articles?search=rest+api → Search
Always validate input:
javascript
const { body, validationResult } = require("express-validator");
app.post("/api/users", [
body("name").trim().notEmpty().withMessage("Name is required"),
body("email").isEmail().normalizeEmail().withMessage("Valid email required"),
body("age").optional().isInt({ min: 0, max: 120 })
], (req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({
error: "Validation failed",
details: errors.array()
});
}
// Process valid data
});
Implement rate limiting:
javascript
const rateLimit = require("express-rate-limit");
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // 100 requests per window
message: {
error: "Too Many Requests",
message: "Please try again after 15 minutes"
}
});
app.use("/api/", limiter);
Return meaningful error messages:
javascript
// ❌ BAD — Generic, unhelpful
res.status(400).json({ error: "Bad request" });
// ✅ GOOD — Specific, actionable
res.status(400).json({
error: "Validation Error",
message: "The provided email address is already registered",
field: "email",
suggestion: "Use the forgot password endpoint to recover your account"
});
Concept 9: REST API vs GraphQL vs gRPC 🆚
What is REST API compared to alternatives?
| Feature |
REST API |
GraphQL |
gRPC |
| Protocol |
HTTP |
HTTP |
HTTP/2 |
| Data Format |
JSON/XML |
JSON |
Protocol Buffers |
| Request Type |
Multiple endpoints |
Single endpoint |
Strongly typed |
| Over-fetching |
Common problem |
Solved |
N/A |
| Under-fetching |
Common problem |
Solved |
N/A |
| Caching |
HTTP caching built-in |
Complex |
Complex |
| Learning Curve |
Low |
Moderate |
High |
| Browser Support |
Excellent |
Good |
Limited |
| Tooling |
Mature |
Growing |
Specialized |
| Best For |
Public APIs, simple use |
Complex data, mobile |
Microservices, low latency |
When to use REST API:
- Building a public API for developers to consume
- Simple CRUD operations
- When HTTP caching is important
- When browser compatibility matters
- When your team is already familiar with REST
When to use GraphQL:
- Mobile apps that need to minimize data transfer
- Complex data requirements with many related resources
- When clients need different data shapes
- Rapid frontend iteration without backend changes
When to use gRPC:
- Internal microservice communication
- When performance and low latency are critical
- Strongly typed contracts between services
- When you control both client and server
Testing REST APIs — Tools You Need
Postman — The most popular REST API testing tool. Create requests, save them in collections, write tests, and generate documentation.
curl — Command line testing:
bash
# GET request
curl https://api.example.com/api/users
# POST request with JSON body
curl -X POST https://api.example.com/api/users \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-token" \
-d '{"name": "Rahul", "email": "rahul@email.com"}'
# DELETE request
curl -X DELETE https://api.example.com/api/users/123 \
-H "Authorization: Bearer your-token"
HTTPie — More readable CLI:
bash
# GET
http GET api.example.com/api/users
# POST
http POST api.example.com/api/users \
name="Rahul" email="rahul@email.com" \
Authorization:"Bearer your-token"
Conclusion
Now you have a thorough understanding of what is REST API — the communication standard that connects virtually every modern web and mobile application.
Here is a quick recap of the 9 powerful concepts:
- ✅ REST Principles — Six constraints that define a truly RESTful API
- ✅ Resources and URLs — Noun-based, hierarchical resource addressing
- ✅ HTTP Methods — GET, POST, PUT, PATCH, DELETE for different operations
- ✅ HTTP Status Codes — Communicating success and failure clearly
- ✅ Request and Response Structure — JSON as the universal data format
- ✅ Authentication — JWT Bearer tokens securing your endpoints
- ✅ API Versioning — Evolving your API without breaking clients
- ✅ Best Practices — Consistent naming, validation, rate limiting, error messages
- ✅ REST vs GraphQL vs gRPC — Choosing the right API style for your needs
What is REST API’s lasting importance? It is the glue of the modern internet. Every app you use — social media, banking, e-commerce, streaming — is built on APIs. Understanding how they work, how to design them well, and how to consume them effectively is not just a backend skill — it is a fundamental skill for anyone building software in 2026.
Related Articles
External Resource
Frequently Asked Questions