Why is API versioning important for a production web API?
Short answer
API versioning lets you evolve an API's contract (adding fields, changing behavior, removing deprecated endpoints) without breaking existing clients that depend on the current behavior.
Advertisement
AModel answer
API versioning lets you evolve an API's contract (adding fields, changing behavior, removing deprecated endpoints) without breaking existing clients that depend on the current behavior. Without versioning, any breaking change forces every consumer to update simultaneously, which is impractical for public APIs or APIs with many independent client teams.
// v1: returns { name: string }
// v2: returns { firstName: string, lastName: string }
// Both versions coexist so old clients keep working during a migration windowReal-world example
A payments API maintains v1 and v2 simultaneously for six months after a breaking schema change, giving integrator partners time to migrate before v1 is eventually deprecated and removed.
Likely follow-ups
- What's the difference between a breaking and non-breaking API change?
- How long should old versions typically be supported?
Related topics