Skip to main content

FastAPI Admin Kit

PyPI version Python versions License Tests

A drop-in admin panel for FastAPI + SQLAlchemy + SQLModel apps, inspired by Django Unfold.

FastAPI Admin Kit Dashboard

📖 Documentation | 🚀 Quick Start | 📦 PyPI

Features

See the Full Features List for every feature with detailed docs links.

  • Zero-Config Auto-Discovery — Register a model, get full CRUD UI automatically
  • SQLAlchemy & SQLModel — Works with both ORMs out of the box
  • Built-in Auth & RBAC — Session-based auth with role-based permissions per model
  • Audit Logging — Every create, update, and delete is recorded with full diffs
  • Modern UI — Tailwind CSS, HTMX, and Alpine.js with dark mode
  • 17 Built-in Widgets — TextInput, Toggle, DatePicker, FileUpload, Wysiwyg, and more
  • Inline Editing — Edit records directly from list view with 3-dot action menu
  • Command PaletteCmd+K / Ctrl+K global search across models and fields
  • JSON API — REST endpoints with JWT token auth for external frontends
  • Dashboard — Configurable stat cards, charts, tables, and progress bars
  • CLI Toolsfak-admin / fak for superuser management and project scaffolding
  • Pagination — Offset, cursor, or dynamic strategies per model
  • Filters — Text, boolean, relation, and enum sidebar filters
  • File Uploads — Built-in local storage backend with upload widgets
  • Async-First — PostgreSQL, MySQL, and SQLite with auto URL normalization
  • CSRF & Rate Limiting — Security built-in out of the box

Installation

# pip
pip install fastapi-admin-kit

# uv
uv add fastapi-admin-kit

For database-specific async drivers:

# pip
pip install fastapi-admin-kit[postgres]  # PostgreSQL via asyncpg
pip install fastapi-admin-kit[mysql]     # MySQL via aiomysql

# uv
uv add fastapi-admin-kit[postgres]  # PostgreSQL via asyncpg
uv add fastapi-admin-kit[mysql]     # MySQL via aiomysql

For the full experience with uvicorn and JWT support:

# pip
pip install fastapi-admin-kit[full]

# uv
uv add fastapi-admin-kit[full]

Quick Start

import os
import secrets
from contextlib import asynccontextmanager

from fastapi import FastAPI
from sqlalchemy import Column, Float, Integer, String
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import DeclarativeBase, relationship, sessionmaker

from fastapi_admin_kit import Admin
from fastapi_admin_kit.auth.backend import BuiltinAuthBackend
from fastapi_admin_kit.auth.mixins import AuthModelMixin
from fastapi_admin_kit.auth.models import Role, admin_user_roles


class Base(DeclarativeBase):
    pass


class User(AuthModelMixin, Base):
    __tablename__ = "users"
    id = Column(Integer, primary_key=True)
    email = Column(String(255), unique=True, nullable=False)
    full_name = Column(String(255))

    roles = relationship(
        "Role", secondary=admin_user_roles, back_populates="users"
    )


class Product(Base):
    __tablename__ = "products"
    id = Column(Integer, primary_key=True)
    name = Column(String(100), nullable=False)
    price = Column(Float, nullable=False)


DATABASE_URL = os.getenv("DATABASE_URL", "sqlite+aiosqlite:///./app.db")
SECRET_KEY = os.getenv("SECRET_KEY", secrets.token_urlsafe(32))

engine = create_async_engine(DATABASE_URL)
async_session = sessionmaker(engine, class_=AsyncSession)


@asynccontextmanager
async def lifespan(app: FastAPI):
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)
    await admin.setup()
    yield
    await engine.dispose()


app = FastAPI(lifespan=lifespan)
admin = Admin(
    app=app,
    engine=engine,
    base=Base,
    secret_key=SECRET_KEY,
    auth_model=User,
    auth_backend=BuiltinAuthBackend(),
)
admin.register(Product)

Run with:

pip install fastapi-admin-kit[full]
uvicorn main:app --reload

Open http://localhost:8000/admin/ and log in with:

  • Email: admin@example.com
  • Password: admin

!!! warning Change the default password immediately in production!

CLI Usage

Both the full name and the short alias work interchangeably:

# Create a superuser
fak-admin createsuperuser -e admin@example.com -p mypassword
fak createsuperuser -e admin@example.com -p mypassword       # short alias

# List all admin users
fak-admin users
fak users

# Change a user's password
fak-admin changepassword -e admin@example.com -p newpassword
fak changepassword -e admin@example.com -p newpassword

# Scaffold a new fastapi project
fak init myproject

# Permission management
fak createpermissions --base myapp.models.Base
fak createpermissions myapp.models.User myapp.models.Product

All commands accept -d DATABASE_URL or read the DATABASE_URL environment variable.

Configuration

Environment Variables

Variable Description Default
DATABASE_URL Async database connection string sqlite+aiosqlite:///./app.db
SECRET_KEY Signing key for sessions/CSRF/JWT (min 32 chars) Auto-generated if unset

Admin Options

from fastapi_admin_kit import Admin
from fastapi_admin_kit.config import ThemeConfig

admin = Admin(
    app=app,
    engine=engine,
    base=Base,
    secret_key=SECRET_KEY,
    title="My Admin",           # Admin panel title
    admin_path="/admin",        # URL prefix
    dark_mode_default=False,    # Dark mode on by default
    # Auth
    auth_backend=BuiltinAuthBackend(),
    # Environment badge
    environment_label="Production",
    environment_color="danger",
)

Database Support

  • SQLite (default, built-in via aiosqlite)
  • PostgreSQL: pip install fastapi-admin-kit[postgres] + set DATABASE_URL=postgresql+asyncpg://...
  • MySQL: pip install fastapi-admin-kit[mysql] + set DATABASE_URL=mysql+aiomysql://...

Optional Dependencies

Extra Packages When to use
full uvicorn, pyjwt Running the dev server or using JWT API auth
postgres asyncpg PostgreSQL databases
mysql aiomysql MySQL databases
sqlmodel sqlmodel Using SQLModel models
docs mkdocs, mkdocs-material Building documentation

Security

  • Session cookies use SameSite=Strict and Secure by default
  • CSRF protection on all state-changing requests
  • Rate limiting on authentication endpoints
  • Passwords hashed with bcrypt
  • SQL injection prevention via identifier validation
  • Secret key validated to be >= 32 characters at startup

Development

# Install with dev dependencies
uv sync

# Run tests with coverage
uv run pytest --cov=fastapi_admin_kit

# Lint
uv run ruff check fastapi_admin_kit/

# Format
uv run ruff format fastapi_admin_kit/

# Build distribution
uv build

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_admin_kit-0.3.0.tar.gz (222.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_admin_kit-0.3.0-py3-none-any.whl (313.1 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_admin_kit-0.3.0.tar.gz.

File metadata

  • Download URL: fastapi_admin_kit-0.3.0.tar.gz
  • Upload date:
  • Size: 222.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fastapi_admin_kit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0672ff394575346f52dc81bb7249d84302a2e8c3b07844f520b7c8c8d4f3097a
MD5 929dba5ff9a74bcfa02bf6be9f64e492
BLAKE2b-256 1dab1047771f1966ba0d19fd973a88f7ab059e375311c1410946a19f4fa744eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_admin_kit-0.3.0.tar.gz:

Publisher: release.yml on borhanst/fastapi-admin-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastapi_admin_kit-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_admin_kit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bba56bd20ace3b43b0199cf85e3aeaa053b8aa37207915feed80b440b8124764
MD5 25a4cca1b9f30ba2b1886e453d3eac10
BLAKE2b-256 fc5a4c8a15d784adc4617e79d8aad5f7114a84ec748850e716a9b6c7f31afd56

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_admin_kit-0.3.0-py3-none-any.whl:

Publisher: release.yml on borhanst/fastapi-admin-kit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

This release

0.3.0 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page