すべての記事に戻る
Engineering

Designing APIs That Age Well

Good APIs are quiet. They do exactly what you expect and keep working long after you stop thinking about them. Here is how to design for that kind of longevity.

Mara Devlin8 分で読めます

The best APIs feel obvious in hindsight. You call a method, it does the one thing its name promises, and it keeps behaving that way through a dozen releases. That reliability is not luck. It is the result of a handful of decisions made early and defended over time.

Name things for the caller, not the implementation

An API is a promise written in method names. When you name a function after how it works internally, every refactor threatens to break that promise. Name it after what the caller wants, and the implementation stays free to change underneath.

The test is simple: read the call site out loud. If a new teammate can guess what happens without opening the source, the name is doing its job.

Make the common case effortless

Most callers want the same thing most of the time. Design the default path so it requires no configuration, then layer options on top for the rare cases. An API that demands five parameters for a routine task will be wrapped in a helper by the first team that uses it, and now you maintain two interfaces instead of one.

Every required argument is a small tax you charge on every single call. Charge it only when the value genuinely cannot be inferred.

Version the contract, not the code

Breaking changes are not the enemy. Surprise is. When you must break something, give it a new name or a new version and let the old path keep working through a clear deprecation window. Callers will forgive a migration they can plan for. They will not forgive a silent change that breaks production on a Tuesday.

An API that ages well is one you can stop thinking about. Build it so the people who depend on it can too.