fastapi-versioning

raw JSON →
0.10.0 verified Fri May 01 auth: no python maintenance

API versioning for FastAPI web applications. The current version is 0.10.0, with no recent releases; the library appears to be in maintenance mode. Supports header, hostname, URL prefix, and query parameter versioning schemes. Requires Python >=3.6 and FastAPI.

pip install fastapi-versioning
error ImportError: cannot import name 'VersionedFastAPI' from 'fastapi_versioning'
cause Using an old import path (e.g., from fastapi_versioning.versioned_fastapi import VersionedFastAPI).
fix
Use: from fastapi_versioning import VersionedFastAPI
error AssertionError: Versioning scheme not supported
cause Using an unsupported versioning scheme or misconfigured parameters.
fix
Set versioning_scheme to one of 'header', 'hostname', 'url', 'query'.
deprecated Version 0.10.0 is likely the last release; the library is in maintenance mode. Consider migrating to alternatives like 'fastapi-versionize' or 'fastapi-versioning-lite'.
fix Migrate to a maintained library.
gotcha The decorator order matters: apply @version before @app.get, otherwise versioning may not work correctly.
fix Ensure @version is placed above the route decorator.
gotcha Using the same endpoint path for multiple versions can cause conflicts; fastapi-versioning does not deduplicate automatically.
fix Design distinct paths per version or use header-based versioning.

Minimal example using decorator-based versioning with URL prefix.

from fastapi import FastAPI
from fastapi_versioning import VersionedFastAPI, version

app = FastAPI()

@version(1, 0)
@app.get("/")
def read_root():
    return {"Hello": "v1"}

app = VersionedFastAPI(app, version_format="{major}.{minor}", prefix_format="/v{major}.{minor}")