HTTP Methods
When a browser or application communicates with a server, it uses a set of standard rules called HTTP.
HTTP methods define what action you want to perform on the server.
What Are HTTP Methods?
HTTP methods describe the type of request sent from a client (browser) to a server.
Each method has a specific purpose, and using the correct one is very important.
Why HTTP Methods Matter
- They make communication clear and predictable
- They help servers understand intent
- They follow REST API standards
Almost every API you work with relies on HTTP methods.
Common HTTP Methods
The most commonly used HTTP methods are:
- GET
- POST
- PUT
- DELETE
GET – Retrieve Data
The GET method is used to request data from a server.
- Does not modify server data
- Safe and cacheable
- Commonly used for reading information
GET /users HTTP/1.1
POST – Send New Data
The POST method is used to send new data to the server.
- Creates new resources
- Data is sent in the request body
- Not cached by default
POST /users HTTP/1.1
Content-Type: application/json
PUT – Update Existing Data
The PUT method updates an existing resource.
- Replaces existing data
- Used when full update is required
PUT /users/101 HTTP/1.1
DELETE – Remove Data
The DELETE method removes data from the server.
- Deletes a resource
- Should be used carefully
DELETE /users/101 HTTP/1.1
Real-World API Example
A typical user API might behave like this:
- GET → Fetch user details
- POST → Create a new user
- PUT → Update user profile
- DELETE → Remove user
Using correct methods keeps APIs clean and consistent.
Status Codes (Quick Intro)
Servers respond with HTTP status codes.
- 200 – Success
- 201 – Created
- 400 – Bad Request
- 404 – Not Found
- 500 – Server Error
Status codes help you understand server responses.
Common Beginner Mistakes
- Using GET to send sensitive data
- Using POST for everything
- Ignoring response status codes
Correct method usage improves security and clarity.
Thumb Rules
- GET = Read
- POST = Create
- PUT = Update
- DELETE = Remove
What Comes Next?
Now that you understand HTTP methods, the next step is making actual requests from JavaScript.
In the next lesson, we will use the Fetch API.