Requests

HTTP methods

Choose GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS according to the action a request asks the server to perform.

The method describes the request’s intent.

  • GET retrieves a resource.
  • POST submits data or starts an action.
  • PUT replaces a resource.
  • PATCH updates part of a resource.
  • DELETE removes a resource.
  • HEAD asks for the headers a GET would return, without the body.
  • OPTIONS asks which communication options are available.

For a notes API, you might use:

GET /notes
POST /notes
GET /notes/42
PATCH /notes/42
DELETE /notes/42

HTTP does not automatically enforce what a method means. A server could delete data in response to GET, but that would violate expectations and cause problems for caches, crawlers, and browsers.

Lesson completed

Take this course offline

Get every free book, course edition, and software download.

Get the download library →