以下是关于FastApi开发框架日常开发中常用到的一些第三方库。
管理
- FastAPI Admin - 功能管理面板,提供用于对数据执行 CRUD 操作的用户界面。目前仅适用于 Tortoise ORM。 参考地址:https://github.com/fastapi-admin/fastapi-admin
- Piccolo Admin - 一个强大而现代的管理 GUI,使用 Piccolo ORM。 参考地址:https://github.com/piccolo-orm/piccolo_admin
- SQLAlchemy Admin - 适用于 SQLAlchemy 模型的 FastAPI/Starlette 管理面板。 参考地址:https://github.com/aminalaee/sqladmin
认证
- AuthX - 用于FastAPI的可定制的认证和Oauth2管理。 参考地址:https://github.com/yezz123/AuthX
- FastAPI Auth - 支持OAuth2密码、JWT访问和刷新令牌的可插拔式的认证。 参考地址:https://github.com/dmontagu/fastapi-auth
- FastAPI Azure Auth - 为你的API提供Azure AD认证,支持单租户和多租户。 参考地址:https://github.com/Intility/fastapi-azure-auth
- FastAPI Cloud Auth - FastAPI和云认证服务 (AWS Cognito, Auth0, Firebase Authentication) 之间的简单集成。. 参考地址:https://github.com/tokusumi/fastapi-cloudauth
- FastAPI Login - 账号管理和认证 (基于 Flask-Login). 参考地址:https://github.com/MushroomMaula/fastapi_login
- FastAPI JWT Auth - JWT 认证 (基于 Flask-JWT-Extended). 参考地址:https://github.com/IndominusByte/fastapi-jwt-auth
- FastAPI Permissions - Row-level 权限控制. 参考地址:https://github.com/holgi/fastapi-permissions
- FastAPI Security - 结合FastAPI的依赖项,实施认证和授权。 参考地址:https://github.com/jacobsvante/fastapi-security
- FastAPI Simple Security - 通过路径操作,来管理开箱即用的API密钥安全。 参考地址:https://github.com/mrtolkien/fastapi_simple_security
- FastAPI Users - 账户管理、认证、授权。 参考地址:https://github.com/fastapi-users/fastapi-users
数据库
ORMs
- FastAPI SQLAlchemy - FastAPI 和 SQLAlchemy 之间的简单集成。 参考地址:https://github.com/mfreeborn/fastapi-sqlalchemy
- Fastapi-SQLA - SQL Alchemy 扩展用于快速 API,支持分页、异步和 pytest。 参考地址:https://github.com/dialoguemd/fastapi-sqla
- FastAPIwee - 基于 PeeWee 模型创建 REST API 的简单方法 参考地址:https://github.com/Ignisor/FastAPIwee
- GINO - 一个基于Python异步,建立在 SQLAlchemy 核心之上轻量级异步 ORM。 参考地址:https://github.com/python-gino/gino
- ORM - 一个异步 ORM. 参考地址:https://github.com/encode/orm
- ormar - Ormar 是一个异步 ORM,可以直接用于FastAPI请求和响应,因此你只需要维护一套模型,包含 Alembic 迁移 参考地址:https://collerek.github.io/ormar/
- FastAPI Example - 在ormar使用FastAPI框架. 参考地址:https://collerek.github.io/ormar/fastapi/
- Piccolo - 一个异步ORM和查询生成器,支持Postgres和SQLite,带有功能 (迁移、安全等). 参考地址:https://github.com/piccolo-orm/piccolo
- FastAPI Examples - 在Piccolo 使用FastAPI框架. 参考地址:https://github.com/piccolo-orm/piccolo_examples
- Prisma Client Python - 一个由Pydantic提供的自动生成的、全部类型安全的ORM,并为你的模式专门定制 - 支持SQLite、PostgreSQL、MySQL、MongoDB、MariaDB等。 参考地址:https://github.com/RobertCraigie/prisma-client-py
- Tortoise ORM - 一个易于使用的异步 ORM(对象关系映射器),灵感来自Django 参考地址:https://tortoise.github.io
- FastAPI Example - 一个 Tortoise-ORM FastAPI 集成的例子. 参考地址:https://tortoise.github.io/examples/fastapi.html
- Tutorial: Setting up Tortoise ORM with FastAPI 参考地址:https://web.archive.org/web/20200523174158/https://robwagner.dev/tortoise-fastapi-setup/
- Aerich - Tortoise ORM 迁移工具. 参考地址:https://github.com/tortoise/aerich
- SQLModel - (由Pydantic和SQLAlchemy驱动)是一个用于与Python代码交互的SQL数据库的库,具有Python对象。 参考地址:https://sqlmodel.tiangolo.com/
Query Builders
- asyncpgsa - 一个用于 SQLAlchemy Core 的 asyncpg的包装器。 参考地址:https://github.com/CanopyTax/asyncpgsa
- Databases - 异步sql查询构建器,基于 SQLAlchemy Core 表达式语言。 参考地址:https://github.com/encode/databases
ODMs
- Beanie - 用于MongoDB的异步Python ODM,基于 Motor 和 Pydantic, 支持数据和模式迁移。 参考地址:https://github.com/roman-right/beanie
- MongoEngine - 一个用于Python的MongoDB文档对象映射器(类似于ORM,但用于文档数据库)。 参考地址:http://mongoengine.org/
- Motor - 异步MongoDB的Python驱动程序。 参考地址:https://motor.readthedocs.io/
- ODMantic - AsyncIO MongoDB ODM 集成 Pydantic 参考地址:https://art049.github.io/odmantic/
Other Tools (其他工具)
- Pydantic-SQLAlchemy - 将SQLAlchemy模型转换为 Pydantic 模型。 参考地址:https://github.com/tiangolo/pydantic-sqlalchemy
- FastAPI-CamelCase - 利用 Pydantic 的CamelCase JSON支持。 参考地址:https://nf1s.github.io/fastapi-camelcase/
- CamelCase Models with FastAPI and Pydantic - Accompanying blog post from the author of the extension. 随之而来的作者扩展的博客文章。 参考地址:https://medium.com/analytics-vidhya/camel-case-models-with-fast-api-and-pydantic-5a8acb6c0eee
开发工具
- FastAPI Code Generator - 从OpenAPI文件创建FastAPI应用程序,从而实现模式驱动的开发。 参考地址:https://github.com/koxudaxi/fastapi-code-generator
- FastAPI Client Generator - 基于OpenAPI规范生成一个mypy和IDE友好的API客户端。 参考地址:https://github.com/dmontagu/fastapi_client
- FastAPI MVC - 开发人员生产力工具,用于制作高质量的FastAPI生产就绪API。 参考地址:https://github.com/fastapi-mvc/fastapi-mvc
- FastAPI Profiler - 一个基于joerick/pyinstrument,检查你的服务性能的FastAPI中间件。 参考地址:https://github.com/sunhailin-Leo/fastapi_profiler
- FastAPI Versioning - API 的版本控制. 参考地址:https://github.com/DeanWay/fastapi-versioning
- Jupyter Notebook REST API - 运行你的Jupyter笔记本作为RESTful API端点。 参考地址:https://github.com/Invictify/Jupter-Notebook-REST-API
- Manage FastAPI - CLI 工具,用于生成和管理 FastAPI 项目。 参考地址:https://github.com/ycd/manage-fastapi
- msgpack-asgi - 自动 MessagePack 内容协商。 参考地址:https://github.com/florimondmanca/msgpack-asgi
邮箱
- FastAPI Mail - 轻量级邮件系统,用于发送电子邮件和附件(单个和批量)。 参考地址:https://github.com/sabuhish/fastapi-mail
其他
- ASGI Correlation ID - 请求ID日志中间件。 参考地址:https://github.com/snok/asgi-correlation-id
- FastAPI Cache - 一个简单的轻量级缓存系统。 参考地址:https://github.com/comeuplater/fastapi_cache
- FastAPI Cache - 一个用于缓存FastAPI响应和函数结果的工具,支持Redis,Memcached,DynamoDB和内存后端。 参考地址:https://github.com/long2ice/fastapi-cache
- FastAPI Chameleon - 增加了Chameleon模板语言到FastAPI的集成。 参考地址:https://github.com/mikeckennedy/fastapi-chameleon
- FastAPI Contrib - 一组有观点的实用程序:分页,身份验证中间件,权限,自定义异常处理程序,MongoDB支持和Opentracing中间件。 参考地址:https://github.com/identixone/fastapi_contrib
- FastAPI CRUDRouter - 一个自动创建和记录CRUD路由的FastAPI路由器,用于你的模型。 参考地址:https://github.com/awtkns/fastapi-crudrouter
- FastAPI Events - 用于FastAPI和Starlette的异步事件调度/处理库。 参考地址:https://github.com/melvinkcx/fastapi-events
- FastAPI FeatureFlags - 简单的FastAPI功能标志的实现。 参考地址:https://github.com/Pytlicek/fastapi-featureflags
- FastAPI Jinja - 增加了Jinja模板语言到FastAPI的集成。 参考地址:https://github.com/AGeekInside/fastapi-jinja
- FastAPI Lazy - 一个懒惰的包,用于使用FastAPI启动你的项目。 参考地址:https://github.com/yezz123/fastapi-lazy
- FastAPI Limiter - 一个用于限制FastAPI请求的工具。 参考地址:https://github.com/long2ice/fastapi-limiter
- FastAPI MQTT - 一个 MQTT 协议的扩展。 参考地址:https://github.com/sabuhish/fastapi-mqtt
- FastAPI Opentracing - Opentracing 中间件和数据库跟踪支持FastAPI。 参考地址:https://github.com/wesdu/fastapi-opentracing
- FastAPI Pagination - FastAPI 分页。 参考地址:https://github.com/uriyyo/fastapi-pagination
- FastAPI Plugins - Redis 和 Scheduler 插件。 参考地址:https://github.com/madkote/fastapi-plugins
- FastAPI ServiceUtils - 用于创建API服务的生成器。 参考地址:https://github.com/skallfass/fastapi_serviceutils
- FastAPI SocketIO - FastAPI 和 SocketIO 的简单集成。 参考地址:https://github.com/pyropy/fastapi-socketio
- FastAPI Utilities - 重用的实用程序:基于类的视图,响应推断路由器,定期任务,计时中间件,SQLAlchemy会话,OpenAPI规范简化。 参考地址:https://github.com/dmontagu/fastapi-utils
- FastAPI Websocket Pub/Sub - Websocket pub/sub 模式,使其在云中的任何地方都可以轻松访问和扩展。 参考地址:https://github.com/authorizon/fastapi_websocket_pubsub
- FastAPI Websocket RPC - 通过 Websockets 的 RPC(双向 JSON RPC)变得简单、健壮和生产就绪。 参考地址:https://github.com/authorizon/fastapi_websocket_rpc
- OpenTelemetry FastAPI Instrumentation - OpenTelemetry 是一个开放的自动跟踪工具包,用于监视应用程序的性能和可用性。 参考地址:https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-fastapi
- Prerender Python Starlette - 一个用于预渲染爬虫的中间件。 参考地址:https://github.com/BeeMyDesk/prerender-python-starlette
- Prometheus FastAPI Instrumentator - 一个可配置和模块化的 Prometheus Instrumentator 用于你的 FastAPI 应用程序。 参考地址:https://github.com/trallnag/prometheus-fastapi-instrumentator
- SlowApi - 限速器(基于 Flask-Limiter)。 参考地址:https://github.com/laurents/slowapi
- Starlette Context - 允许你在项目的任何地方存储和访问请求数据,对于日志记录很有用。 参考地址:https://github.com/tomwojcik/starlette-context
- Starlette Exporter - 一个用于 FastAPI 和 Starlette 的 Prometheus 集成。 参考地址:https://github.com/stephenhillier/starlette_exporter
- Starlette OpenTracing - 对于 Starlette 和 FastAPI 的 Opentracing 支持。 参考地址:https://github.com/acidjunk/starlette-opentracing
- Starlette Prometheus - FastAPI 和 Starlette 的 Prometheus 集成。 参考地址:https://github.com/perdy/starlette-prometheus
- Strawberry GraphQL - 一个基于dataclasses的 Python GraphQL 库。 参考地址:https://github.com/strawberry-graphql/strawberry
接下来我们将对这些第三方库,分别使用单独的文章篇幅来一一介绍,如果你有需要补充的,欢迎联系我们进行追加和补充。