Google Professional Cloud Developer Question 328
Select 3Google Cloud PlatformYou are developing an API that will be consumed by multiple clients, and you need to ensure backward compatibility while rolling out new features. You are using Apigee to manage your APIs. Which of the following practices should you follow to version your API effectively?
- A
Include the version number in the API URL path, such as /v1/resource.
- B
Use request headers to specify the API version dynamically.
- C
Maintain a single API version and update it in place to avoid managing multiple versions.
- D
Deprecate older versions of the API with clear communication to clients before removing them.
- E
Embed the API version in the query parameters, such as ?version=1.
Show answer and explanation
Correct answers: A, B, D
Explanation
Versioning APIs is crucial to ensure backward compatibility and a smooth transition for clients when rolling out new features. Practices such as versioning in the URL path, using headers, and properly deprecating older versions facilitate better API management and client adoption. Apigee supports these practices, enabling developers to manage API versions effectively.
- A. Correct.
Including the version number in the API URL path is a common and widely accepted practice for versioning APIs. It ensures clarity and separation of versions.
- B. Correct.
Using request headers to specify the API version dynamically is another valid method, as it allows clients to request specific versions without altering the URL structure.
- C. Incorrect.
Maintaining a single API version and updating it in place is not recommended, as it can break existing clients and does not support backward compatibility.
- D. Correct.
Deprecating older versions with clear communication is a best practice, as it provides clients sufficient time to migrate to newer versions.
- E. Incorrect.
Embedding the version in query parameters is generally not recommended because it can lead to confusion and inconsistency in API design.