HTTP Verbs: GET, POST, PUT, DELETE
What you'll learn: The four essential HTTP methods that give meaning to every REST API request.
What Are HTTP Verbs?
HTTP verbs (also called methods) are keywords that tell a server what action you want to perform on a resource. Think of them as verbs in a sentence: they describe the action, while the URL identifies the noun (the resource). These methods give semantic meaning to requests—making REST APIs predictable and self-documenting.
The Four Primary HTTP Methods
GET — Retrieve a Resource
GET requests data without changing anything on the server. It's like looking at a book on a shelf without taking it down. GET requests should be safe (no side effects) and idempotent (calling it multiple times produces the same result).
Example: GET /users/123 retrieves user 123's information.
POST — Create a New Resource
POST submits data to create something new. It's like adding a new book to the library. The server typically decides the new resource's identifier.
Example: POST /users with user data creates a new user.
PUT — Update/Replace a Resource
PUT replaces an entire resource with new data. It's like rewriting every page of a specific book. PUT is idempotent—sending the same PUT request multiple times produces the same end result.
Example: PUT /users/123 with complete user data updates user 123.
DELETE — Remove a Resource
DELETE removes a resource from the server. It's like removing a book from the shelf permanently. Also idempotent—deleting the same resource twice has the same effect as deleting it once.
Example: DELETE /users/123 removes user 123.
Why These Matter
These verbs make REST APIs intuitive. Instead of creating custom endpoint names like /getUserById or /deleteUser, you use the HTTP verb to express intent, keeping URLs focused purely on identifying resources.
Key Takeaway: GET retrieves, POST creates, PUT updates/replaces, and DELETE removes—these four HTTP verbs form the foundation of meaningful, self-descriptive REST API operations.