Designing Idempotent APIs for Real-World Applications
Many developers spend most of their time designing an API around good endpoints, payloads in requests, status codes for responses, and how to model data. All these aspects are important; however, without proper consideration for the way things really work in real-world systems, they are insufficient. Real-world systems experience issues with users accidentally clicking a button, networks failing, payment processors resending webhooks for retries, queues re-delivering messages, and even browsers sending requests again after a timeout. The issue here is that the same action could be performed more than once, resulting in the creation of duplicated orders, duplicated payments, duplicated email notifications, etc., which would also lead to inconsistencies in the record.
At this point, idempotency comes into play.
An API is idempotent if calling it the same number of times will have exactly the same effect as calling it once. Idempotence means that if a user submits the same...
Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE