Idempotency just means, calling the same function/endpoint multiple times, with the same arguments, will result in the same state.
if you write an endpoint like /player/increaseScoreByOne it will change the state as often as you call it.
if you write an endpoint like /player/setScoreTo?value=100 it will always result in the same state.
When your request doesn't get through, you can safely make it again without worrying about an inconsistent server state.
Not for 5 year olds, but I hope it helps xD
First of all, thank you for answering.
Considering your reply,
Idempotent: GET, TRACE, OPTIONS
Where do I place DELETE and PUT, and why?
You have to think about one action when thinking about idempotency.
If you call DELETE 100 times, it will still be the same item that is deleted, you remove it from memory, the DB or set a field deleted = true or something. Same goes for PUT, you send an update to the server, but you "set" state to a new state, you don't do stuff like "increase value x", "append string to y" or "subtract 10 from z".
deleted = true
Sure the data will be gone for your next GET request if you issued 1 or 100 DELETEs, but the idea is that the 100 DELETEs end in the same state as the 1 DELETEs
Gotcha!! Thanks buddy :)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.