🔢 API Versioning Language
Master vocabulary for API versioning strategies: URL vs header versioning, stability labels, SemVer conventions, LTS mode, and breaking change identification. Intermediate
An API team debates between two versioning approaches:
- URL versioning:
GET /v2/users - Header versioning:
GET /userswithAPI-Version: 2header
Which approach is generally favoured for public APIs, and why?
Option C correctly describes the practical trade-offs that make URL versioning the dominant choice for public APIs. Both approaches have legitimate use cases:
| Dimension | URL versioning (/v2/users) | Header versioning (API-Version: 2) |
|---|---|---|
| Browser testability | ✓ Paste URL into browser | ✗ Requires curl or Postman |
| CDN caching | ✓ Different URLs cache independently | ✗ Requires Vary header; CDN support varies |
| Log readability | ✓ Version visible in access logs | ✗ Must parse headers to identify version |
| REST purity | ✗ Version in URL is conceptually mixed with the resource identifier | ✓ URL represents the resource; version is metadata |
Real-world convention: Stripe, Twilio, GitHub, and most major public API providers use URL versioning. Header versioning is more common in internal enterprise APIs where consumers are controlled. A hybrid approach is also valid: URL major version + Sunset / Deprecation headers for deprecation signalling.