What are the main API versioning strategies in REST and what are their tradeoffs?

Answer

Three main versioning approaches exist. URL path versioning (/v1/users) is the most common and explicit — version is visible in the URL, easy to route and test, but "pollutes" the URL structure and requires clients to update base URLs. Header versioning (API-Version: 2 or Accept: application/vnd.myapi.v2+json) keeps URLs clean and is semantically correct (the URL identifies the resource, not the version), but it is harder to test in a browser and less visible. Query parameter versioning (/users?version=2) is easy to add but is non-standard and can interfere with caching. URL path versioning is recommended for most public APIs due to visibility and simplicity. Never change a published version — create a new one and run old and new in parallel until clients migrate.