API Fundamentals
/Advanced
Idempotency
Definition
A mathematical and computer science property where an operation can be applied multiple times without changing the result beyond the initial application.
Explain Like I'm New
If you hit an elevator button 1 time, it comes to your floor. If you smash the elevator button 100 times in a row, it still just comes to your floor. The button is Idempotent. The end result is exactly the same no matter how many times you pressed it.
Real World Example
Stripe Payments. If a user clicks 'Pay', but their WiFi drops, they panic and click 'Pay' again. If the `POST /charge` API is NOT idempotent, the user gets charged $100 twice. If the API IS idempotent, the server recognizes the duplicate request and only charges them once.
Common Use Cases
- •Payment gateways
- •Distributed retries
- •Network reliability
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- Is the HTTP `DELETE` method intended to be Idempotent?
intermediate
- How do payment APIs implement Idempotency on `POST` requests (which are normally not idempotent)?