Introduction
A REST API is a way for different applications to communicate with each other over the internet.
For example:
- A mobile app talks to a server
- A website fetches user data
- A payment app sends transaction details
- A frontend React app communicates with a Django backend
All of this communication usually happens using a REST API.
Simple Definition
REST API = A bridge between two systems
REST stands for:
Representational State Transfer
API stands for:
Application Programming Interface
In simple words:
A REST API allows applications to send and receive data using HTTP requests.
Real-World Example
Imagine you are using a food delivery app.
When you:
- Open the app
- Search for pizza
- Place an order
The app sends requests to the server using a REST API.
The server then:
- Processes your request
- Fetches data from the database
- Sends the response back
REST API Architecture

How REST API Works
A REST API works using HTTP methods.
Common HTTP Methods
| Method | Purpose |
|---|---|
| GET | Fetch data |
| POST | Create new data |
| PUT | Update data |
| DELETE | Remove data |
Example of REST API
Fetch User Data
GET /api/users/1Response
{
"id": 1,
"name": "Babu",
"email": "babu@example.com"
}Here:
- Client sends request
- Server processes it
- Server returns JSON data
Main Components of a REST API
1. Client
The application that sends requests.
Examples:
- Mobile app
- Website
- React frontend
2. Server
The system that processes requests and returns responses.
Examples:
- Django
- FastAPI
- Flask
- Node.js
3. Database
Stores application data.
Examples:
- PostgreSQL
- MySQL
- MongoDB
Why REST APIs Are Popular
1. Easy to Understand
REST APIs use simple HTTP methods.
2. Fast Communication
Applications can exchange data quickly.
3. Platform Independent
Works with:
- Web apps
- Mobile apps
- Desktop apps
4. Uses JSON Format
JSON is lightweight and easy to read.
Example:
{
"product": "Laptop",
"price": 50000
}REST API Example in Real Life
| Application | REST API Usage |
|---|---|
| Fetch posts and likes | |
| Amazon | Product listing and orders |
| Google Maps | Location data |
| Paytm | Payment processing |
| Netflix | Movies and recommendations |
Common REST API Response Codes
| Status Code | Meaning |
|---|---|
| 200 | Success |
| 201 | Created |
| 400 | Bad Request |
| 401 | Unauthorized |
| 404 | Not Found |
| 500 | Internal Server Error |
Important Features of REST API
1. Stateless
Each request is independent.
The server does not remember previous requests.
2. Client-Server Architecture
Frontend and backend work separately.
3. Cacheable
Responses can be stored temporarily for better performance.
4. Uniform Interface
Uses standard URLs and HTTP methods.
REST API URL Example
https://example.com/api/usersBreakdown:
| Part | Meaning |
|---|---|
| https:// | Secure connection |
| example.com | Domain |
| /api/ | API section |
| /users | Resource |