HTTP Methods Overview
GET
Data retrievalSafe and idempotent
POST
Data creationNon-idempotent
PUT
Data modificationIdempotent
DELETE
Data deletionIdempotent
GET - Retrieval
Used to retrieve data. Does not modify server state.Single Resource Retrieval
List Retrieval
Retrieving Related Data
GET Method Characteristics:
- Safe: Does not modify server state
- Idempotent: Same request multiple times yields same result
- Cacheable: Can be cached by browser/proxy
- Parameters are passed via URL query string
POST - Creation
Used to create new resources.Simple Creation
Complex Creation (With Related Data)
Batch Creation
POST Method Characteristics:
- Unsafe: Modifies server state
- Non-idempotent: Same request multiple times may create duplicate resources
- Not cacheable
- Parameters are passed via Body
- Typically returns the ID of the created resource
PUT - Modification
Used to modify existing resources.Full Update
Partial Update (PATCH Style)
Status Change
PUT Method Characteristics:
- Unsafe: Modifies server state
- Idempotent: Same request multiple times yields same result
- Typically replaces the entire resource
- Parameters are passed via Body
- Returns empty response or updated resource on success
DELETE - Deletion
Used to delete resources.Single Deletion
Soft Delete
Delete With Related Data
Batch Deletion
DELETE Method Characteristics:
- Unsafe: Modifies server state
- Idempotent: Deleting an already deleted resource yields same result
- Generally returns empty response on success (204 No Content)
- Consider soft delete (using deleted_at column)
Method Selection Guide
Selection Criteria
| Operation | Method | Example |
|---|---|---|
| Single retrieval | GET | /api/user/get?id=1 |
| List retrieval | GET | /api/user/list?page=1 |
| New creation | POST | /api/user/create |
| Full update | PUT | /api/user/update?id=1 |
| Partial update | PUT | /api/user/updatePartial?id=1 |
| Deletion | DELETE | /api/user/remove?id=1 |