Junior — Middle
Explain the principle of idempotency in the context of REST API.
sobes.tech AI
Answer from AI
Idempotency in the context of REST API means that repeated calls to the same request with the same parameters will not change the server's state after the first call.
In simpler terms, if you send the same request multiple times, the result will be the same as if you sent it once.
Examples:
- The GET method is always idempotent — it simply retrieves data.
- The PUT method is usually idempotent — it updates a resource to a certain state.
- The DELETE method should be idempotent — deleting a resource multiple times will not change the result after the first deletion.
This is important for the reliability and predictability of the API, especially in case of network failures and repeated requests.