Common API mistakes and how to avoid them

Covering the “how to avoid” part here

  • Be stingy with data you are sending through your APIs. Figure out what’s the absolute minimum amount of data that satisfies the requirements you are trying to meet.
  • Represent upstream data internally as a Domain Object. You can both circumvent some bugs and provide a more consistent API by doing this.
  • Try to name attributes of objects in your API responses in such a way that they can be forward compatible with any future updates.
  • Apply Robustness Principle: “Be conservative in what you do, be liberal in what you accept from others.” Ensure all the API responses follow conventions and best practices but be accepting of inconsistent forms of requests (whenever you can) and normalize them into a consistent format at your end.

Full post here, 15 mins read