Why is versioning important in REST APIs to prevent breaking changes?
Think about how clients rely on API behavior staying the same.
Versioning lets the API keep old behavior for existing clients while allowing new versions with changes. This prevents breaking clients unexpectedly.
Given this API URL, what version is being requested?
GET /api/v2/users
Look at the part after /api/ in the URL.
The URL contains v2 which means version 2 of the API is requested.
Consider an API without versioning. The API changes the response format. What is the likely result for existing clients?
Think about how clients expect data in a certain format.
Without versioning, clients get unexpected data formats and may fail because they rely on the old format.
Semantic versioning uses numbers like MAJOR.MINOR.PATCH. Which part signals a breaking change?
Breaking changes usually require a big version update.
Increasing the MAJOR version signals breaking changes, so clients know to expect possible incompatibilities.
You maintain a REST API used by many clients. You want to add a new required field to a response without breaking existing clients. Which versioning strategy should you use?
Think about how to keep old clients working while adding new features.
Creating a new version lets new clients use the new field while old clients keep working with the old version.