API Semantic Versioning – Why Declare a Public API?

apisemantic-versioning

from semver.org:

Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. However it is done, it should be precise and comprehensive.

Why are we forced to declare a public API? Why can't I use it for my own website that has no API?

Perhaps I am wrong with the definition. For me it is a part of the site desigedn for other developers (i.e.: api.example.com) that allow them to query my website and get the result into structured data (json, xml…).

Best Answer

It requires a public API in order to effectively apply it's versioning pattern.

For example:

Bug fixes not affecting the API increment the patch version

Backwards compatible API additions/changes increment the minor version, and...

Backwards incompatible API changes increment the major version.

What represents your API is subjective, as they even state in the SemVer doc:

This may consist of documentation or be enforced by the code itself.

I think that is where your misunderstanding is. An API is not necessarily...

a part of the site designed for other developers that allow them to query my website and get the result into structured data

It could be that. Who knows. It could also be a set of documented UX rules.

If you can't effectively outline what your website's API is, then maybe SemVer isn't appropriate.