API Academy
Master Modern APIs
HTTP Verbs
Understanding the different HTTP methods and their purposes in RESTful APIs.
Idempotent
Multiple identical requests have the same effect as a single request
Safe Methods
Methods that don't modify server state (read-only operations)
CRUD Operations
Create, Read, Update, Delete - basic operations on data
Request Body
Data sent with the request, typically in POST/PUT/PATCH methods
Retrieve Data
Used to retrieve data from a server. Should be safe and idempotent - no side effects.
GET /api/users/123
GET /api/products?category=electronics
Create Resource
Used to create new resources on the server. Not idempotent - multiple calls create multiple resources.
POST /api/users
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com"
}
Update/Replace
Used to update or completely replace an entire resource. Idempotent operation.
PUT /api/users/123
Content-Type: application/json
{
"name": "John Smith",
"email": "johnsmith@example.com"
}
Partial Update
Used to partially update a resource with only the changed fields.
PATCH /api/users/123
Content-Type: application/json
{
"email": "newemail@example.com"
}
Remove Resource
Used to delete a resource from the server. Idempotent operation.
DELETE /api/users/123
DELETE /api/posts/456
Get Headers Only
Similar to GET but returns only headers, no response body. Useful for checking resource existence.
HEAD /api/users/123
# Returns headers only, no body
Get Allowed Methods
Returns the HTTP methods supported by the server for a specific resource.
OPTIONS /api/users
# Response: Allow: GET, POST, PUT, DELETE
Establish Tunnel
Establishes a tunnel to the server, typically used for HTTPS through proxies.
CONNECT example.com:443 HTTP/1.1
Diagnostic Tool
Performs a message loop-back test along the path to the target resource.
TRACE /api/users
HTTP methods have different properties that affect how they should be used. Safe methods (GET, HEAD, OPTIONS) don't modify server state. Idempotent methods (GET, PUT, DELETE, HEAD, OPTIONS) can be called multiple times with the same result. Understanding these properties is crucial for proper API design and client implementation.
- 1Use GET for retrieving data, never for operations that change server state
- 2Use POST for creating resources and non-idempotent operations
- 3Use PUT for complete resource replacement, PATCH for partial updates
- 4Make sure DELETE operations are idempotent and safe to retry
- 5Use appropriate status codes with each method (201 for POST success, 204 for DELETE success)
- 6Include proper Content-Type headers when sending request bodies
- 7Design URLs as nouns (resources) and use HTTP methods as verbs (actions)