skillfed

fastapi-sessions

Ready-to-use session library for FastAPI

fastapi-sessions v0.3.2 75.1K downloads/30d#14,750 on PyPI109
Permissive license MIT Abandoned released

What it is and what it does

FastAPI-Sessions is a session authentication library for FastAPI that uses dependency injection to protect routes. It provides an abstract architecture for session backends (how sessions are stored) and frontends (how session IDs are extracted from requests), allowing you to mix and match implementations. The package ships with an in-memory backend and a signed-cookie frontend, and supports Pydantic models for session data validation.

The library is designed to integrate cleanly with FastAPI's auto-generated documentation and dependency injection system. However, the project has been archived since July 2023 and is no longer maintained, meaning no updates, security patches, or support for newer FastAPI or Python versions are forthcoming.

Use it for:

  • Add cookie-based session authentication to a FastAPI application without writing session middleware from scratch.
  • Protect individual routes with session verification using FastAPI's dependency injection system.
  • Build a custom session backend by extending the abstract backend interface to store sessions in a database or cache.
  • Validate session data using Pydantic models to ensure type safety and automatic OpenAPI documentation.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Adds session authentication to FastAPI applications using dependency injection, with pluggable backends and frontends for storing and retrieving session data.

No. The project is archived and abandoned since July 2023 with no maintenance or security updates. For new FastAPI projects, use actively maintained alternatives. For existing projects already using it, evaluate whether you can migrate to a maintained session library or implement session handling directly, as the lack of ongoing support poses a long-term risk.

Install

fastapi-sessions on PyPI

pip

pip install fastapi-sessions

uv

uv add fastapi-sessions

poetry

poetry add fastapi-sessions

Installing fastapi-sessions

Before you install

Installation is straightforward with only two runtime dependencies (fastapi and itsdangerous). However, the project is archived and abandoned as of July 2023, with no updates for over two years, so maintenance and security patches are no longer expected.

License in practice

MIT license is permissive and places no restrictions on commercial or private use, modification, or distribution.

Quickstart

pip install fastapi-sessions

from fastapi import FastAPI, Depends
from fastapi_sessions.backends.implementations import InMemoryBackend
from fastapi_sessions.frontends.implementations import SessionCookie

app = FastAPI()
backend = InMemoryBackend()
session_cookie = SessionCookie(secret_key="your-secret-key")

@app.get("/")
async def read_root(session_data=Depends(session_cookie)):
    return {"session": session_data}

Requires Python 3.6.1 or later; project is archived and no longer maintained, so compatibility with recent FastAPI or Python versions is not guaranteed.

Verify before relying

  • Whether the in-memory backend is suitable for production use or multi-worker deployments.
  • Compatibility with FastAPI versions released after the last update in July 2023.
  • Whether custom backends and frontends are documented or straightforward to implement.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.6.1,<4.0)
Install friction low — pure-Python wheel
Runtime dependencies 2 — fastapi, itsdangerous
Maintenance abandoned — 1,798 days since the last release
Last repo commit (repository archived)
First released
Downloads 75,112/month — #14,750 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: fastapi_sessions-0.3.2-py3-none-any.whl

Keywords: sessions, cookies, authorization, fastapi

Framework :: AsyncIOIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTP :: Session

Tags

fastapi session authenticationsession management fastapifastapi cookies sessionsdependency injection sessionsfastapi user sessionssession backend fastapisigned cookie sessions
abandonedsession-auth

More Session packages