LearnModern FundamentalsArchitecture and ProtocolsHTTP Verbs and Idempotency

HTTP Verbs and Idempotency

The HTTP protocol defines a series of methods (verbs) that indicate the desired action to be performed on a resource.

The Main Verbs

  1. GET: Retrieves data. Should not have side effects on the server.
  2. POST: Creates a new resource. It is not idempotent (identical requests create multiple resources).
  3. PUT: Updates an existing resource or creates it if it doesn't exist. It is idempotent.
  4. DELETE: Removes a resource.

What is Idempotency?

A method is idempotent if executing multiple identical requests has the same effect on the server as a single request.

  • GET is idempotent.
  • PUT is idempotent.
  • POST is not idempotent.

In Heapi, you can test how your API behaves when repeating these commands in the integrated terminal or the visual interface.

Complete Lesson