While there are several HTTP methods, the primary and most frequently used ones, which are often considered the "major" ones, are not limited to four, but are typically considered five: POST, GET, PUT, PATCH, and DELETE. These methods directly correlate to the fundamental Create, Read, Update, and Delete (CRUD) operations commonly performed in web applications.
Here's a breakdown of these major HTTP methods:
Major HTTP Methods
Method | Purpose | CRUD Operation |
---|---|---|
GET | Retrieves data from a specified resource. | Read |
POST | Submits data to be processed to a specified resource, often creating a new resource. | Create |
PUT | Updates a specified resource. | Update |
PATCH | Partially modifies a specified resource. | Update |
DELETE | Deletes a specified resource. | Delete |
In Depth Look At The Methods
- GET: This method is used to request data from a specified resource. It is primarily intended for data retrieval and should not be used to modify data. GET requests append parameters to the URL. For example:
example.com/users?id=123
- POST: The POST method is used to submit data to be processed to a resource. It is often used when submitting form data or creating new resources. POST requests send data in the request body, so are more secure than GET requests. For example: when submitting a registration form for a new account.
- PUT: This method is used to replace the entire resource at a specified location. If the resource does not exist, it might create it. Use PUT when you want to fully update a resource.
- PATCH: Unlike PUT, PATCH is used for partial updates to a resource. If only some fields need to be changed, PATCH is the appropriate method.
- DELETE: As the name suggests, DELETE is used to remove a resource from a specified location.
Key Takeaways
- These five methods (GET, POST, PUT, PATCH, DELETE) cover the most important operations performed in HTTP.
- GET is primarily for reading data.
- POST is commonly used to create resources.
- PUT and PATCH are for updating resources, with PUT replacing entirely and PATCH partially updating the data.
- DELETE is for removing resources.
- While other HTTP methods exist, these five are the core ones used in web development.