FastAPI versioning library
==
[](https://codecov.io/gh/community-of-python/fast-version)
[](https://mypy.readthedocs.io/en/stable/getting_started.html#strict-mode-and-configuration)
[](https://pypi.python.org/pypi/fast-version)
[](https://pypistats.org/packages/fast-version)
[](https://github.com/community-of-python/fast-version/stargazers)
<img src="./logo.svg" width="250" />
This package adds versioning by Accept-header into FastAPI
## Quickstart:
### Installation
```shell
$ pip install fast-version
```
### Defining app and routes
```python
import fastapi
from fast_version import VersionedAPIRouter, init_fastapi_versioning
VERSION_HEADER: str = "application/vnd.some.name+json"
ROUTER_OBJ = VersionedAPIRouter()
@ROUTER_OBJ.get("/test/")
async def test_get() -> dict:
return {"version": (1, 0)}
@ROUTER_OBJ.get("/test/")
@ROUTER_OBJ.set_api_version((2, 0))
async def test_get_v2() -> dict:
return {"version": (2, 0)}
app = fastapi.FastAPI()
app.include_router(ROUTER_OBJ)
init_fastapi_versioning(app=app, vendor_media_type=VERSION_HEADER)
```
### Query Examples
```bash
# call 1.0 version
curl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=1.0'
curl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json'
curl -X 'GET' 'https://test.ru/test/'
# call 2.0 version
curl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=2.0'
```
Raw data
{
"_id": null,
"home_page": null,
"name": "fast-version",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.10",
"maintainer_email": null,
"keywords": "fastapi, versioning, accept-header",
"author": "Artur Shiriev",
"author_email": "Artur Shiriev <me@shiriev.ru>",
"download_url": "https://files.pythonhosted.org/packages/df/1e/e5918e6b312cb7b4d6175b2c40b684861b8f4bc1233a7de3625a13490eb7/fast_version-1.4.3.tar.gz",
"platform": null,
"description": "FastAPI versioning library\n==\n[](https://codecov.io/gh/community-of-python/fast-version)\n[](https://mypy.readthedocs.io/en/stable/getting_started.html#strict-mode-and-configuration)\n[](https://pypi.python.org/pypi/fast-version)\n[](https://pypistats.org/packages/fast-version)\n[](https://github.com/community-of-python/fast-version/stargazers)\n\n<img src=\"./logo.svg\" width=\"250\" />\n\nThis package adds versioning by Accept-header into FastAPI\n\n## Quickstart:\n\n### Installation\n\n```shell\n$ pip install fast-version\n```\n\n### Defining app and routes\n```python\nimport fastapi\n\nfrom fast_version import VersionedAPIRouter, init_fastapi_versioning\n\n\nVERSION_HEADER: str = \"application/vnd.some.name+json\"\nROUTER_OBJ = VersionedAPIRouter()\n\n\n@ROUTER_OBJ.get(\"/test/\")\nasync def test_get() -> dict:\n return {\"version\": (1, 0)}\n\n\n@ROUTER_OBJ.get(\"/test/\")\n@ROUTER_OBJ.set_api_version((2, 0))\nasync def test_get_v2() -> dict:\n return {\"version\": (2, 0)}\n\n\napp = fastapi.FastAPI()\napp.include_router(ROUTER_OBJ)\ninit_fastapi_versioning(app=app, vendor_media_type=VERSION_HEADER)\n```\n\n### Query Examples\n```bash\n# call 1.0 version\ncurl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=1.0'\n\ncurl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json'\n\ncurl -X 'GET' 'https://test.ru/test/'\n\n# call 2.0 version\ncurl -X 'GET' 'https://test.ru/test/' -H 'accept: application/vnd.some.name+json; version=2.0'\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Fastapi versioning package with accept header",
"version": "1.4.3",
"project_urls": {
"repository": "https://github.com/modern-python/fast-version"
},
"split_keywords": [
"fastapi",
" versioning",
" accept-header"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3f4ba148d5ba2be2068632501e5a32e9665a92ac2462fd9f17e524e3742de5eb",
"md5": "383b35da99090e25e8858dcd6a2e646d",
"sha256": "845e46c2e975308e521e9623cfc0fbaf7c6413c3a357a2ba8a971fc9ad988b24"
},
"downloads": -1,
"filename": "fast_version-1.4.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "383b35da99090e25e8858dcd6a2e646d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.10",
"size": 5440,
"upload_time": "2025-08-15T16:12:03",
"upload_time_iso_8601": "2025-08-15T16:12:03.280524Z",
"url": "https://files.pythonhosted.org/packages/3f/4b/a148d5ba2be2068632501e5a32e9665a92ac2462fd9f17e524e3742de5eb/fast_version-1.4.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "df1ee5918e6b312cb7b4d6175b2c40b684861b8f4bc1233a7de3625a13490eb7",
"md5": "9870c6fee56eb1fc85945acca8b24f06",
"sha256": "f2e0ddd8a0e244423fe2817608ece6f115121fae8db3e243afdcb2d9d2bbe84b"
},
"downloads": -1,
"filename": "fast_version-1.4.3.tar.gz",
"has_sig": false,
"md5_digest": "9870c6fee56eb1fc85945acca8b24f06",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.10",
"size": 4233,
"upload_time": "2025-08-15T16:12:04",
"upload_time_iso_8601": "2025-08-15T16:12:04.067089Z",
"url": "https://files.pythonhosted.org/packages/df/1e/e5918e6b312cb7b4d6175b2c40b684861b8f4bc1233a7de3625a13490eb7/fast_version-1.4.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-15 16:12:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "modern-python",
"github_project": "fast-version",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "fast-version"
}