A REST API (Representational State Transfer API) is a way for two systems to communicate with each other over the internet. It works on the principle of making requests and receiving responses between a client (like a web browser or mobile app) and a server (where the data is stored). Most modern REST APIs transmit data in JSON format, although they can also utilize XML, images, or even HTML.
REST APIs rely on HTTP methods (such as GET, POST, PUT, PATCH, DELETE) to perform actions on resources. These actions align with CRUD operations (Create, Read, Update, Delete), which define how data is managed over the web.
👉 Important Note: REST is an architectural style for designing APIs, while HTTP is the communication protocol used to transfer data. REST defines how the API should behave, and HTTP defines how communication happens. They are not the same thing, but they usually work together.
🔑 Key Features of REST APIs
Stateless: Each request must contain all the information needed. The server does not store client session details.
Client-Server Model: The client and server operate independently, making the system scalable.
Cacheable: Responses can be cached (stored temporarily) to improve speed and performance.
Uniform Interface: REST APIs adhere to consistent rules, including standard URLs, HTTP methods, and status codes.
Layered System: APIs can be built in multiple layers, which improves security and scalability.
⚙️ Common HTTP Methods in REST API
1. GET Method
Used to read or fetch a resource.
Returns data (JSON/XML) with a status code
200 OKif successful.If not found, it may return
404 NOT FOUND.
Example:
GET /customers/45This request fetches details of the customer with ID 45.
2. POST Method
Used to create a new resource.
On success, the server returns status
201 CREATED.
Example:
POST /customers
{
"name": "Ravi Kumar",
"email": "[email protected]"
}
This request creates a new customer.
⚠️ Note: POST is not idempotent, meaning multiple calls can create multiple records.
3. PUT Method
Used to update an entire resource or create it if it does not exist.
Replaces the resource at the given URL.
Example:
PUT /customers/45
{
"name": "Aarav Patel",
"email": "[email protected]"
}
This replaces customer 45’s details.
4. PATCH Method
Used to partially update a resource.
Only sends the fields that need changes.
Example:
PATCH /customers/45
{
"email": "[email protected]"
}
This updates only the email of customer 45.
PUT vs PATCH
| Feature | PUT | PATCH |
|---|---|---|
| Update Type | Replaces full resource | Updates specific fields |
| Data Required | Entire data | Only changes |
| Idempotent | Yes | Not always |

Join the conversation! Your thoughts help the community grow.