Idempotency

Jatin Tayal
1 min readAug 4, 2023

As software engineers, we are constantly looking for ways to increase the reliability and scalability of system 🌐 we work upon and improve the overall customer 👤 experience. One concept that really helps in achieving these things is the idea of making Idempotent APIs.

An idempotent API is one that can be called multiple times with the same input parameters and the resulting state of the system will be the same as if it had only been called once. This is a crucial property for APIs that may experience network errors, timeouts, or other unexpected issues, as it ensures that retries won’t cause unintended side effects or data corruption. With an idempotent API, we don’t have to worry 🙅🏻 about accidentally making duplicate requests and causing unintended side effects. We can simply call the API as many times as we need to, and it will always produce the same resultant state of system. This makes it much easier to write robust code 🧑🏻‍💻.
A real life example where API idempotency plays an important role is in the case of online transactions i.e. when we make any online transactions, we expect it to process without double charging our card even in case of payments failures and retries. Here, we would want the server to process our requests only once irrespective of how many times the same request payload comes to it.

Overall, I think idempotent APIs are a really interesting concept that more developers should be aware of as it helps in building more reliable, scalable and robust software.

--

--