Card 10/ 10

RecapDifficulty: Intermediate1 min

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.
The six methods against the two promises
MethodSafeIdempotentRetry automatically
GETYesYesYes
QUERYYesYesYes
PUTNoYesYes
DELETENoYesYes
PATCHNoNoNo
POSTNoNoNo, without an idempotency key