The HTTP protocol defines a set of request methods to indicate the desired action to be performed on a given resource. Designing professional REST APIs requires strict adherence to method semantics, idempotency, and safety.
| Method | CRUD Action | Safe? | Idempotent? | Request Body Allowed? | Standard Success Status |
|---|---|---|---|---|---|
GET | Read / Retrieve | Yes | Yes | No | 200 OK |
POST | Create / Action | No | No | Yes | 201 Created |
PUT | Replace / Overwrite | No | Yes | Yes | 200 OK or 204 No Content |
PATCH | Partial Update | No | No (Technically) | Yes | 200 OK |
DELETE | Destroy / Remove | No | Yes | Optional (Rare) | 204 No Content |
GET, HEAD, and OPTIONS are safe (read-only).GET, PUT, DELETE, HEAD, and OPTIONS are idempotent.PUT vs PATCH DistinctionA frequent source of API design errors is confusing PUT and PATCH:
PUT (Full Resource Replacement):PUT replaces the entire target resource representation. Any existing fields omitted from the payload are reset to default values or set to null!
PATCH (Partial Modification):PATCH applies partial delta updates. Only the provided keys are mutated; unmentioned fields remain unchanged:
DRF simplifies method routing in APIViews:
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| REST Principles | Status Codes |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.