API Design Is a Contract. Design It Like One.

D
Dick Edidiong Bassey
·

An API is not an internal implementation detail. The moment another system calls it, it becomes a contract.

The discipline of API design starts with versioning. Every public API endpoint should be versioned from day one. The day you need to make a breaking change (and you will), the version prefix is the mechanism that lets you do it without breaking existing consumers.

Resource naming should be consistent and predictable. Use nouns, not verbs. /orders not /getOrders. Plural nouns consistently.

Error responses should be as carefully designed as success responses. A 400 returning {"error": "invalid"} is not an error response. It is a riddle. Return a structured error with a machine-readable code and a human-readable message.

Document the API before you build it. If you cannot describe it clearly, you have not designed it clearly enough to build it correctly.

— Dick Bassey | DevDick | 2023