liveBook · Manning

Versioning

As explained in The Design of Web APIs, Second Edition

An API version scheme is a convention for identifying and expressing different versions of an API.

API versioning identifies states of an interface contract as consumers see it. It is not the same as versioning implementation code: a security fix or internal restructuring can change the implementation without changing the API version. Decide on a scheme and how consumers will identify a version before the first breaking change, so they know what to expect. section 15.4.1 section 15.4.5

A banking API evolves

Suppose version 1.0 offers account operations. Adding a transaction-listing operation is backward compatible, so the API becomes 1.1; adding merchant details to its response makes it 1.2. Replacing /accounts/{accountNumber} with /accounts/{IBAN} breaks existing requests and calls for a major version change to 2.0. Removing a cards list that account responses always included is another breaking change. section 15.4.2

Choose an identifier that helps consumers interpret releases:

  • Semantic API versions use MAJOR.MINOR: increment MAJOR for breaking changes and MINOR for backward-compatible changes. This treatment leaves out PATCH because implementation-only bug fixes do not change the API contract. section 15.4.2
  • Date-based versions use a deployment date, such as YYYY-MM-DD or YYYY-MM. They show which release is newer but not what changed; consumers must consult documentation. Consider them for frequent or regular releases. section 15.4.2

An identifier is only part of a versioning policy. Set out when versions change, how breaking changes are handled, how many older versions remain supported, and for how long. The scheme also needs a consumer-facing representation: a path segment such as /v1 is one option. A team or organization will likely use a shared policy rather than decide independently for every API. section 15.1.2 section 15.4.5

Before publishing a breaking version, list the modifications and ask who uses the affected behavior, whether the benefit justifies migration, and whether both versions can be exposed. Parallel versions can give consumers time to update, but separate instances may be costly or incompatible with database changes. A single instance can adapt older requests and responses, although missing data or changed behavior may make some conversions impossible. Record the changes and update the API description and version number. section 15.5 section 15.5.3 section 15.1.3

How The Design of Web APIs, Second Edition covers it

How deep it goes
Compares identifier schemes and versioning-policy decisions, then examines breaking-change impact and options for exposing concurrent versions.
Examples
Uses banking account and transaction changes, semantic and date-based identifiers, and concurrent-version implementation scenarios.
What it assumes
Assumes familiarity with API consumers and requests while defining version identifiers and distinguishing interface changes from implementation changes.
What you can do after
Evaluate/understand API version choices and assess whether a breaking release warrants consumer migration and concurrent support.
How it connects
Connects versioning to backward compatibility, breaking changes, interface contracts, API architecture, and change logs.

Also explained in

Compare how 27 books explain versioning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.