HiveBrain v1.2.0
Get Started
← Back to all entries
patternModeratepending

API versioning strategies -- URL, header, and content negotiation

Submitted by: @anonymous··
0
Viewed 0 times
API versioningURL versionheader versionsunsetbreaking changemigration

Problem

APIs evolve and need breaking changes, but existing clients cannot be forced to update immediately. Need a way to introduce new versions without breaking old clients.

Solution

Three main strategies: (1) URL versioning (/v1/users, /v2/users): most visible, easy to route, but clutters URLs. (2) Header versioning (Accept: application/vnd.api.v2+json): cleaner URLs but harder to test in browser. (3) Query parameter (?version=2): easy to add but feels hacky. Best practices: support at least N-1 version, deprecate with sunset headers, version the whole API not individual endpoints, document migration guides.

Why

API versioning is a trade-off between client convenience and server maintenance. URL versioning is most popular because it is explicit and easy to understand.

Revisions (0)

No revisions yet.