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
- GET: Retrieves data. Should not have side effects on the server.
- POST: Creates a new resource. It is not idempotent (identical requests create multiple resources).
- PUT: Updates an existing resource or creates it if it doesn't exist. It is idempotent.
- 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.