Card 10/ 10
Recap: HTTP Methods and Their Guarantees
The method is a promise to every client, cache and proxy about what repeating the request will do.
The method is the part of an API call that everything between client and server understands.
- An API call is an HTTP request: method, path, headers, an optional body, and a status code back.
- GET reads, POST asks the server to process, PUT replaces, PATCH changes part, DELETE removes.
- Safe methods ask for no change; idempotent methods leave the same state however often they are sent.
- GET vs POST is chosen by what the operation does, not the size of its input.
- PUT sends the whole resource; PATCH sends changes and is idempotent only when they set values.
- QUERY is a safe, idempotent read with a body.
- A GET must never change data, because software sends GETs without asking anyone.
| Method | Safe | Idempotent | Retry automatically |
|---|---|---|---|
| GET | Yes | Yes | Yes |
| QUERY | Yes | Yes | Yes |
| PUT | No | Yes | Yes |
| DELETE | No | Yes | Yes |
| PATCH | No | No | No |
| POST | No | No | No, without an idempotency key |
← → move through sections and cards