# Choose API Versioning Strategy

Date: 2024-05-03

# Status

Proposed

# Context

API versioning is crucial for managing changes and ensuring backward compatibility without disrupting existing clients. As our API evolves, we need a method to version the API that meets our goals for visibility, simplicity, maintenance, and flexibility. Two common strategies considered are URI-based and Header-based versioning.

# Decision

We have decided to implement URI-based versioning for our API. This decision is based on our need for high visibility of the API version, ease of use for developers and clients, and the straightforward caching benefits provided by the distinct URIs for each version.

# Consequences

Choosing URI-based versioning has several consequences:

  1. Positive Outcomes:

    • Visibility and Simplicity: Developers can easily see and understand the version they are working with directly in the URL.
    • Ease of Testing: Direct accessibility through the URL makes initial testing simpler using common tools like browsers or CURL.
    • Effective Caching: The distinct URIs for each version simplify HTTP-level caching mechanisms.
  2. Negative Outcomes:

    • URL Pollution: Version numbers in URLs can lead to perceived pollution, making the URLs less clean.
    • Maintenance Challenges: Each version change requires updates to the URLs, potentially leading to broken links and the need for redirects or aliasing, which could complicate maintenance.

# References

  1. Postman Blog on API Versioning: This article provides a detailed overview of various API versioning strategies including URL, query parameter, and header versioning. It also emphasizes the importance of choosing a versioning strategy early in the API design phase to minimize the impact of breaking changes.

  2. Akana's Guide on API Versioning Best Practices: Akana offers a comprehensive guide on best practices for API versioning. The guide highlights the necessity of backward compatibility, the importance of keeping API documentation updated, and adapting versioning strategies to business requirements.