REST stands for Representational State Transfer. It is a type of API (Application Programming Interface) that helps clients send HTTP requests to a server and receive responses, usually in XML or JSON format.
Commonly Used HTTP Methods
REST APIs typically use the following five common HTTP methods to communicate with servers:
- GET
- POST
- PUT
- PATCH
- DELETE
GET Method
The GET method is used to retrieve data from the server.
On success, it returns HTTP 200 (OK).
On failure:
404 (Not Found) → Resource does not exist.
400 (Bad Request) → Invalid request.
Example:
GET /user/123
POST Method
The POST method is used to create a new resource in the database.
On success, it returns HTTP 201 (Created).
Example:
POST /user
{
"userId": "1234",
"name": "Siva"
}
PUT Method
The PUT method is used to update an entire resource.
If the resource exists → It is updated.
If the resource does not exist → A new resource is created.
Example:
PUT /user/1234
{
"userId": "1234",
"name": "Kumar"
}
*PATCH Method
*
The PATCH method is used to partially update a resource.
It sends only the fields that need to be modified, instead of replacing the whole resource.
Example:
PATCH /user/1234
{
"name": "Kumar"
}
DELETE Method
The DELETE method is used to remove a resource from the database.
On success, it typically returns HTTP 200 (OK) or 204 (No Content).
Example:
DELETE /user/1234
✅ With these methods, REST APIs make communication between client and server simple, consistent, and standardized.
Top comments (0)