What is the advantage of the Idempotent API and the danger of the non-idempotent one?

Doradla Hari Krishna
Javarevisited
Published in
6 min readJan 30, 2024

--

Hey there! If you’re not a Medium member, you can still read the full article by following this friend link. I hope you enjoy it :)

If you are a software engineer, then throughout your career you will hear this term, Idempotency.But

  1. What is it?
  2. Why is it important?
  3. Where do we need this?
  4. How do you implement idempotent APIs?
  5. How do you deal with non-idempotent APIs?
Photo by Niclas Illg on Unsplash

When I joined the Amazon Payments team as a software engineer intern, we were integrating with a new payment processor. During the discussion of payment processor API contracts, I heard this word idempotency said by a senior engineer: “Is this charge API idempotent in nature?

What is it?

  • Idempotency is the nature or property of API requests that makes sure that executing the same operation multiple times yields the same result as if it were executed only once.
  • Whenever we are designing APIs, state machines, or distributed systems, it is very important to evaluate whether individual actions or operations are to be made idempotent or not.

Be with me for an interesting real world…

--

--

Doradla Hari Krishna
Javarevisited

Software Engineer who likes writing about tech concepts