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/91/d7/c3df062d42dd37ee0b5e16b6e2711e70f92cf629eedafe5c1156c726f014/fast_version-1.4.4.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.4",
"project_urls": {
"repository": "https://github.com/modern-python/fast-version"
},
"split_keywords": [
"fastapi",
" versioning",
" accept-header"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "418c99ee820307096fcb6a7afbeab852e853f1c259cb93475c04541c7e165914",
"md5": "874cab0602be3f9ce53ebbf21fb1c3a9",
"sha256": "e10323139df13aa8f95013e90b138e23289eea682cf701f55eb033659c7d12ec"
},
"downloads": -1,
"filename": "fast_version-1.4.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "874cab0602be3f9ce53ebbf21fb1c3a9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.10",
"size": 5414,
"upload_time": "2025-10-19T16:27:31",
"upload_time_iso_8601": "2025-10-19T16:27:31.388610Z",
"url": "https://files.pythonhosted.org/packages/41/8c/99ee820307096fcb6a7afbeab852e853f1c259cb93475c04541c7e165914/fast_version-1.4.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "91d7c3df062d42dd37ee0b5e16b6e2711e70f92cf629eedafe5c1156c726f014",
"md5": "eb78bb90c27fdf8eaf73b12c3a981b42",
"sha256": "27e02a34af1464d644d2adcb840e53f3c7446317cd5fbfcc8fb07ede3869f1f4"
},
"downloads": -1,
"filename": "fast_version-1.4.4.tar.gz",
"has_sig": false,
"md5_digest": "eb78bb90c27fdf8eaf73b12c3a981b42",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.10",
"size": 4244,
"upload_time": "2025-10-19T16:27:32",
"upload_time_iso_8601": "2025-10-19T16:27:32.450333Z",
"url": "https://files.pythonhosted.org/packages/91/d7/c3df062d42dd37ee0b5e16b6e2711e70f92cf629eedafe5c1156c726f014/fast_version-1.4.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-19 16:27:32",
"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"
}