Awesome FastAPI
repository·main·Indexed 11 days ago
https://github.com/mjhea0/awesome-fastapiA curated list of high-quality tools, libraries, and resources for the FastAPI ecosystem. This directory includes extensions for admin panels, authentication, ORMs (SQLAlchemy, Tortoise, Piccolo), MongoDB ODMs (Beanie, ODMantic), cybersecurity tools, developer productivity frameworks, deployment guides for serverless and PaaS/IaaS, and project boilerplates.
What's inside Awesome FastAPI
- Awesome FastAPI is a curated collection of resources, tools, and extensions for the FastAPI web framework. It is designed to help developers find high-quality third-party extensions (for Admin, Auth, Databases, etc.), hosting solutions, boilerplates, and educational resources to build high-performance RESTful APIs with Python.
Explore Open Source FastAPI Projects
mainA variety of production-grade or educational projects are built with FastAPI. Key examples include:
- Observability:
fastapi-observabilityimplements the three pillars (Traces via Tempo, Metrics via Prometheus, Logs via Loki) using OpenTelemetry. - Task Queues:
fastapi-celerydemonstrates integration with Celery, RabbitMQ, Redis, and Flower. - Real-time/Websockets:
fastapi-websocket-broadcastfor websocket broadcasting andredis-streams-fastapi-chatfor Redis Streams-backed chat. - Security & Auth:
Dispatchfor managing security incidents andJeffQLfor GraphQL/JWT authentication. - Microservices:
Balifor Cloud Native Microservices using FastAPI and gRPC. - CRUD Examples: Available in both
AsyncandSyncflavors via TestDriven.io.
- Observability:
Access Official FastAPI Resources
mainFor core information regarding the FastAPI framework, use the following official channels:
- Documentation: The primary source for API references and usage guides.
- Tutorial: A step-by-step guide for learning FastAPI features.
- Source Code: The official repository on GitHub.
- Discord: Community chat for real-time support and discussion.
Deploy FastAPI with Docker Images
mainSeveral pre-configured Docker images are available to help ship FastAPI applications efficiently:
- inboard: General-purpose Docker images for FastAPI apps.
- uvicorn-gunicorn-fastapi-docker: High-performance image using Uvicorn managed by Gunicorn (supports Python 3.6 and 3.7).
- uvicorn-gunicorn-poetry: Uses Gunicorn with Uvicorn workers and manages dependencies via Poetry. Supports AMD64 and ARM64.
- uvicorn-poetry: Uses Uvicorn ASGI server and Poetry for dependency management. Optimized for Kubernetes and supports AMD64 and ARM64.
Follow FastAPI Best Practices
mainTo ensure your FastAPI applications are maintainable and production-ready, refer to these resources:
- FastAPI Best Practices: A community-curated collection of best practices.
- Clean Architecture: Use examples like
fastapi-clean-exampleto implement structured, maintainable backends. - Advanced Stacks: Explore combinations like
FastAPI-Dishka-FastStream(FastAPI, dishka, faststream, sqlalchemy, pydantic) for robust service layers.
Deploy FastAPI using Serverless Frameworks
mainTo run FastAPI in a serverless environment, you can use several providers and adapters:
Adapters
- Mangum: An essential adapter for running ASGI applications (like FastAPI) on AWS Lambda and API Gateway.
Frameworks & Compute
- AWS Lambda: Use with the Mangum adapter.
- Google Cloud Functions: Serverless execution.
- Azure Functions: Serverless execution.
- Vercel: Deployment platform.
- Google Cloud Run: Container-based serverless execution.
Learn FastAPI through Tutorials and Courses
mainThere are several structured learning paths available for mastering FastAPI:
Specialized Tutorials
- Async SQLAlchemy: Using SQLAlchemy asynchronously with FastAPI.
- Machine Learning: Deploying Keras models with FastAPI, Redis, and Docker.
- Testing: Developing and testing asynchronous APIs with Pytest, or using property-based testing with Hypothesis and Schemathesis.
- Architecture: Implementing service abstraction and separation of concerns.
- Real-time: Using WebSockets for data streaming.
- Production: Running FastAPI with Gunicorn and systemd.
Comprehensive Courses
- Test-Driven Development (TDD): Building, testing, and deploying microservices with FastAPI and Docker (via TestDriven.io).
- Modern APIs: Creating cloud-native APIs (via Talk Python).
- Full Web Apps: Building complete web applications (via Talk Python).
- Celery Integration: Adding asynchronous task processing with Celery (via TestDriven.io).
Deploy FastAPI on PaaS and IaaS
mainFastAPI can be hosted on various cloud platforms:
PaaS (Platforms-as-a-Service)
- AWS Elastic Beanstalk
- Fly: Offers specific tutorials for FastAPI deployment.
- Google App Engine
- Heroku: Supports standard deployments and machine learning model hosting.
- Microsoft Azure App Service
IaaS (Infrastructure-as-a-Service)
- AWS EC2
- Google Compute Engine
- Digital Ocean
- Linode
Scaffold FastAPI projects with Boilerplates
mainUse various boilerplate templates to jumpstart your FastAPI development depending on your stack requirements:
Full Stack & Modern Web
- Full Stack FastAPI and PostgreSQL: Includes FastAPI, React, SQLModel, PostgreSQL, Docker, and GitHub Actions (developed by Sebastián Ramírez).
- Full Stack FastAPI and MongoDB: Includes FastAPI, MongoDB, Docker, Celery, and React.
- FastAPI and React Template: Uses FastAPI, TypeScript, Docker, PostgreSQL, and React.
- FastAPI Nano: Uses a factory pattern architecture.
Machine Learning & Data Science
- FastAPI Model Server Skeleton: Production-ready skeleton for serving ML models.
- cookiecutter-spacy-fastapi: Quick deployment of spaCy models.
- cookiecutter-fastapi: Template for ML projects using Poetry, Azure Pipelines, and pytest.
Database & ORM Specific
- FastAPI and Tortoise ORM: Simple template using Tortoise-ORM.
- FastAPI + SQLAlchemy 2 + PostgreSQL Template: Dockerized with
modern-didependency injection and Alembic migrations. - fastapi-alembic-sqlmodel-async: Uses Alembic and async SQLModel.
- fastapi-gino-arq-uvicorn: High-performance async REST API using GINO, Arq, Uvicorn, Redis, and PostgreSQL.
Specialized Scaffolding
- openapi-python-client: Generates modern Python clients from FastAPI OpenAPI specs.
- Pywork: Yeoman generator for scaffolding.
- FastAPI template (s3rius): Supports SQLAlchemy, multiple databases, CI/CD, Docker, and Kubernetes.
Select a MongoDB ODM or Driver
mainFor MongoDB integration, consider these options:
- Beanie: Asynchronous ODM based on Motor and Pydantic; supports data/schema migrations.
- ODMantic: AsyncIO MongoDB ODM integrated with Pydantic.
- MongoEngine: Document-Object Mapper for MongoDB.
- Motor: The standard asynchronous Python driver for MongoDB.
Select an Admin panel for FastAPI
mainSeveral third-party admin panels are available to provide a user interface for CRUD operations on your data:
- FastAPI Admin: Functional admin panel; currently only works with the Tortoise ORM.
- FastAPI Amis Admin: High-performance and easily extensible framework.
- Piccolo Admin: Modern GUI specifically for the Piccolo ORM.
- SQLAlchemy Admin: Works with SQLAlchemy models.
- Starlette Admin: Supports SQLAlchemy, SQLModel, MongoDB, and ODMantic.
Select an Authentication and Authorization library
mainChoose an authentication/authorization tool based on your specific requirements:
- OAuth2 & Identity Providers:
- AuthX: Customizable OAuth2 management.
- FastAPI Azure Auth: Azure AD authentication (single/multi-tenant).
- FastAPI Cloud Auth: Integration with AWS Cognito, Auth0, and Firebase.
- FastAPI Zitadel Auth: OAuth2 using the Zitadel IAM platform.
- JWT & Token Management:
- FastAPI Auth: Supports OAuth2 Password Flow with JWT access/refresh tokens.
- FastAPI JWT Auth: JWT authentication (inspired by Flask-JWT-Extended).
- Access Control & Permissions:
- FastAPI Casbin Auth: Supports RBAC, ReBAC, and ABAC via Casbin.
- FastAPI Permissions: Provides row-level permissions.
- FastAPI Security: Implements auth as FastAPI dependencies.
- User & Account Management:
- FastAPI Users: Comprehensive account management, authentication, and authorization.
- FastAPI Login: Account management (based on Flask-Login).
- Other Auth Methods:
- FastAPI Simple Security: Out-of-the-box API key security.
- FastAPI Login: Account management and authentication.
- OAuth2 & Identity Providers: