📚Dev Reference
HTTP Methods (REST)
When to use GET, POST, PUT, PATCH, and DELETE.
Explanation
RESTful APIs use specific HTTP verbs to represent different actions on a resource.
Examples
Read
Output
GET /users
Update
Output
PATCH /users/1
Code Examples
Verbs
GET - Retrieve data (Idempotent)
POST - Create new data
PUT - Replace existing data (Idempotent)
PATCH - Partially update data
DELETE - Remove data (Idempotent)💡 Tips
- GET requests should never change server state
- PUT replaces the whole resource; PATCH only changes fields
- POST is the only non-idempotent standard method
⚠️ Common Pitfalls
- Using GET for sensitive actions like deleting a user