{"id":15683459,"url":"https://github.com/wiseaidev/aioredis_fastapi","last_synced_at":"2025-08-09T21:06:57.676Z","repository":{"id":53921490,"uuid":"521724998","full_name":"wiseaidev/aioredis_fastapi","owner":"wiseaidev","description":"An asynchronous redis based session backend for FastAPI powered applications(WIP, requires testing).","archived":false,"fork":false,"pushed_at":"2024-06-17T21:25:47.000Z","size":242,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-02T09:55:14.990Z","etag":null,"topics":["fastapi","redis","redis-database","redis-session"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/aioredis-fastapi/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wiseaidev.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-05T17:33:16.000Z","updated_at":"2024-08-06T00:43:41.146Z","dependencies_parsed_at":"2023-11-13T21:24:16.958Z","dependency_job_id":"855e6d56-7cd9-4da6-bb9e-b8b1cae02d9f","html_url":"https://github.com/wiseaidev/aioredis_fastapi","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"25e64308b09deb3c85482921f25264d1e9b94dfa"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Faioredis_fastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Faioredis_fastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Faioredis_fastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Faioredis_fastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wiseaidev","download_url":"https://codeload.github.com/wiseaidev/aioredis_fastapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252889669,"owners_count":21820225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","redis","redis-database","redis-session"],"created_at":"2024-10-03T17:05:40.834Z","updated_at":"2025-05-07T13:45:21.034Z","avatar_url":"https://github.com/wiseaidev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"================\naioredis_fastapi\n================\n\n.. image:: https://dl.circleci.com/status-badge/img/gh/wiseaidev/aioredis_fastapi/tree/main.svg?style=svg\n        :target: https://dl.circleci.com/status-badge/redirect/gh/wiseaidev/aioredis_fastapi/tree/main\n\n.. image:: https://img.shields.io/badge/License-GPLv3-blue.svg\n   :target: https://github.com/wiseaidev/aioredis_fastapi/blob/main/LICENSE\n   :alt: License\n\n.. image:: https://raw.githubusercontent.com/wiseaidev/aioredis_fastapi/main/assets/banner.jpeg\n   :target: https://github.com/wiseaidev/aioredis_fastapi/\n   :alt: Banner\n\n\n\n**aioredis_fastapi** is an asynchronous `redis based session`_ backend for FastAPI powered applications.\n\n🚸This repository is currently under testing, kind of production-ready.🚸\n\n\n🛠️ Requirements\n---------------\n\n**aioredis_fastapi** requires Python 3.9 or above.\n\nTo install Python 3.9, I recommend using `pyenv`_. You can refer to `this section`_ of the readme file on how to install poetry and pyenv into your linux machine.\n\n🚨 Installation\n---------------\n\nWith :code:`pip`:\n\n.. code-block:: console\n\n   python3.9 -m pip install aioredis-fastapi\n\nor by checking out the repo and installing it with `poetry`_:\n\n.. code-block:: console\n\n   git clone https://github.com/wiseaidev/aioredis_fastapi.git \u0026\u0026 cd aioredis_fastapi \u0026\u0026 poetry install\n\n\n🚸 Usage\n--------\n\n.. code-block:: python3\n\n   from typing import Any\n   from fastapi import Depends, FastAPI, Request, Response\n   from aioredis_fastapi import (\n       get_session_storage,\n       get_session,\n       get_session_id,\n       set_session,\n       del_session,\n       SessionStorage,\n   )\n\n   app = FastAPI(title=__name__)\n\n\n   @app.post(\"/set-session\")\n   async def _set_session(\n       request: Request,\n       response: Response,\n       session_storage: SessionStorage = Depends(get_session_storage),\n   ):\n       session_data = await request.json()\n       await set_session(response, session_data, session_storage)\n\n\n   @app.get(\"/get-session\")\n   async def _get_session(session: Any = Depends(get_session)):\n       return session\n\n\n   @app.post(\"/del-session\")\n   async def _delete_session(\n       session_id: str = Depends(get_session_id),\n       session_storage: SessionStorage = Depends(get_session_storage),\n   ):\n       await del_session(session_id, session_storage)\n       return None\n\n\n🛠️ Custom Config\n----------------\n\n.. code-block:: python3\n\n   from aioredis_fastapi import settings\n   from datetime import timedelta\n   import random\n\n   settings(\n      redis_url=\"redis://localhost:6379\",\n      session_id_name=\"session-id\",\n      session_id_generator=lambda: str(random.randint(1000, 9999)),\n      expire_time= timedelta(days=1)\n   )\n\n\n🌐 Interacting with the endpoints\n---------------------------------\n\n.. code-block:: python3\n\n   from httpx import AsyncClient\n   import asyncio\n   from aioredis_fastapi.config import settings\n\n   async def main():\n       client = AsyncClient()\n       r = await client.post(\"http://127.0.0.1:8000/set-session\", json=dict(a=1, b=\"data\", c=True))\n       r = await client.get(\"http://127.0.0.1:8000/get-session\", cookies={settings().session_id_name: \"ssid\"})\n       print(r.text)\n       return r.text\n\n   loop = asyncio.new_event_loop()\n   asyncio.set_event_loop(loop)\n   try:\n       loop.run_until_complete(main())\n   finally:\n       loop.close()\n       asyncio.set_event_loop(None)\n\n\n🎉 Credits\n----------\n\nThe following projects were used to build and test :code:`aioredis_fastapi`.\n\n- `python`_\n- `poetry`_\n- `pytest`_\n- `flake8`_\n- `coverage`_\n- `rstcheck`_\n- `mypy`_\n- `pytestcov`_\n- `tox`_\n- `isort`_\n- `black`_\n- `precommit`_\n\n\n👋 Contribute\n-------------\n\nIf you are looking for a way to contribute to the project, please refer to the `Guideline`_.\n\n\n📝 License\n----------\n\nThis program and the accompanying materials are made available under the terms and conditions of the `GNU GENERAL PUBLIC LICENSE`_.\n\n.. _GNU GENERAL PUBLIC LICENSE: http://www.gnu.org/licenses/\n.. _redis based session: https://github.com/duyixian1234/fastapi-redis-session\n.. _Guideline: https://github.com/wiseaidev/aioredis_fastapi/blob/main/CONTRIBUTING.rst\n.. _this section: https://github.com/wiseaidev/frozndict#%EF%B8%8F-requirements\n.. _pyenv: https://github.com/pyenv/pyenv\n.. _poetry: https://github.com/python-poetry/poetry\n.. _python: https://www.python.org/\n.. _pytest: https://docs.pytest.org/en/7.1.x/\n.. _flake8: https://flake8.pycqa.org/en/latest/\n.. _coverage: https://coverage.readthedocs.io/en/6.3.2/\n.. _rstcheck: https://pypi.org/project/rstcheck/\n.. _mypy: https://mypy.readthedocs.io/en/stable/\n.. _pytestcov: https://pytest-cov.readthedocs.io/en/latest/\n.. _tox: https://tox.wiki/en/latest/\n.. _isort: https://github.com/PyCQA/isort\n.. _black: https://black.readthedocs.io/en/stable/\n.. _precommit: https://pre-commit.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseaidev%2Faioredis_fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiseaidev%2Faioredis_fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseaidev%2Faioredis_fastapi/lists"}