Recall & Review
beginner
What is API versioning and why is it important?
API versioning is a way to manage changes in an API over time. It helps keep old clients working while allowing new features or fixes in newer versions. This avoids breaking apps that use the API.
Click to reveal answer
beginner
Name three common API versioning strategies.
1. URL path versioning (e.g., /v1/resource)<br>2. Query parameter versioning (e.g., /resource?version=1)<br>3. Header versioning (using custom headers like 'Accept-Version')
Click to reveal answer
intermediate
How does URL path versioning work in FastAPI?
You include the version number in the URL path, like '/v1/items'. In FastAPI, you create separate routers for each version and include them with different prefixes.
Click to reveal answer
intermediate
What is a benefit of header versioning over URL versioning?
Header versioning keeps URLs clean and stable. Clients specify the version in HTTP headers, so the URL stays the same. This can be better for caching and hides version details from the URL.
Click to reveal answer
intermediate
How can you implement query parameter versioning in FastAPI?
You add a query parameter like '?version=1' to your endpoints. In FastAPI, you read this parameter in your path operation function and route logic based on its value.
Click to reveal answer
Which API versioning strategy includes the version number in the URL path?
✗ Incorrect
URL path versioning puts the version directly in the URL, like '/v1/resource'.
In FastAPI, how do you typically separate different API versions using URL path versioning?
✗ Incorrect
FastAPI uses routers with prefixes like '/v1' and '/v2' to separate versions.
What is a downside of using query parameter versioning?
✗ Incorrect
Query parameters can clutter URLs and may cause caching issues.
Which header is commonly used for header versioning in APIs?
✗ Incorrect
'Accept-Version' is a common custom header to specify API version.
Why is API versioning important?
✗ Incorrect
Versioning helps keep old clients working while allowing API improvements.
Explain three common API versioning strategies and how you might implement them in FastAPI.
Think about how the version info is passed: in the URL, query, or headers.
You got /3 concepts.
Describe the advantages and disadvantages of URL path versioning versus header versioning.
Consider URL clarity and client ease of use.
You got /3 concepts.