r/FastAPI • • Sep 05 '25

Tutorial I just added 5 new interactive lessons on FastAPI Dependencies

53 Upvotes

Hi everyone!

I just added 5 new interactive lessons on FastAPI Dependencies to FastAPIInteractive.com.

The lessons cover:

Everything runs in the browser, no setup needed. You can code, run, and test APIs right on the site.

Would love feedback from the community on how I can make these lessons better šŸ™


r/FastAPI • • Nov 13 '23

feedback request šŸš€FastAPI boilerplate (starter project)

53 Upvotes

Hey, guys, for anyone who might benefit (or would like to contribute)

Yet another FastAPI Boilerplate (starter project) to help you productizing Machine Learning or just creating an API šŸš€
https://github.com/igorbenav/FastAPI-boilerplate

Features:

āš”ļø Fully async
šŸš€ Pydantic V2 and SQLAlchemy 2.0
šŸ” User authentication with JWT
šŸ¬ Easy redis caching
šŸ‘œ Easy client-side caching
🚦 ARQ integration for task queue
🚚 Easy running with docker compose
āš™ļø Efficient querying (only queries what's needed)
šŸ›‘ Rate Limiter dependency
šŸ‘® FastAPI docs behind authentication and hidden based on the environment
šŸ„‡Possibility to create user tiers and limit endpoint usage by tier
āŽ˜ Out of the box pagination support
🦾 Easily extendable
šŸ¤øā€ā™‚ļø Flexible

Improvements are coming, issues and pull requests always welcome 🚧
https://github.com/igorbenav/FastAPI-boilerplate


r/FastAPI • • Apr 13 '26

Other FastAPI gives you the spec. UIGen gives you the full React Frontend. Zero code.

52 Upvotes

Hey everyone,

I’m a huge fan of FastAPI. The fact that it generates an OpenAPI spec out of the box is its true superpower. But I noticed that while we get amazing documentation (Swagger UI / ReDoc) for free, we still have to manually build the internal tools, dashboards, and admin panels to actually use the data easily.

So I built the other half of the equation.

UIGen - point it at your FastAPI /openapi.json URL, and get a fully interactive React frontend in seconds.

npx @uigen-dev/cli serve http://127.0.0.1:8000/openapi.json

# UI is live at http://localhost:4400

How it fits the FastAPI ecosystem

FastAPI is all about types and specs. UIGen follows that philosophy:

  1. Pydantic Validation: Because your spec includes the constraints from your Pydantic models, UIGen automatically builds Zod validation on the frontend to match.

  2. Interactive, not just Docs: Swagger UI is for testing endpoints. UIGen is for managing resources. It handles the "ListView -> DetailView -> EditForm" flow as a cohesive app.

What it generates (from your FastAPI code)

  • Sidebar nav mapped to your API tags/resources.

  • Smart Tables with sorting, pagination, and filtering (derived from your query params).

  • Dynamic Forms derived from your Pydantic models.

  • Detail Views with related resource links.

  • Auth UI - handles Bearer tokens and credential injection via a built-in proxy.

  • Wizards: Large models are automatically split into multi-step forms.

  • Complex Actions: Non-CRUD endpoints show up as custom action buttons.

How it works

It parses your /openapi.json into a custom Intermediate Representation (IR). A pre-built React SPA (shadcn/ui + TanStack) reads that IR and renders the UI. A Vite dev server serves the app and proxies API calls to your FastAPI backend, handling CORS headers so you don't have to fiddle with middleware during dev.

Honest Limitations

  • Circular Models: If you have deeply nested recursive Pydantic models, resolution might skip the deepest levels.

  • Edit View: Works best if you have a standard GET /{id} endpoint for your items.

  • And many other edge cases.

Try it now

If you have a FastAPI app running locally:

npx @uigen-dev/cli serve http://localhost:8000/openapi.json

Or try it on one of the example yaml files in the repo

Would love to hear thoughts from the FastApi community. Of course, this isn't meant to replace a custom consumer-facing frontend, but for internal tools, rapid prototyping, or providing a UI for your API consumers, it’s a massive time-saver.

Happy coding!


r/FastAPI • • Dec 30 '25

Question FastAPI + Pydantic V2: Is anyone else using it to build AI microservices?

52 Upvotes

Hey r/FastAPI community!

I’ve been diving deep intoĀ FastAPIĀ lately, especially withĀ Pydantic V2Ā and its shiny new features (like computed fields and strict validation). With the AI/LLM boom happening right now, I’ve started building async microservices for AI pipelines things like prompt chaining, RAG systems, and real-time inference endpoints.What I’ve noticed: FastAPI’s native async support + Pydantic V2’s performance feels perfect for handling streaming responses from models likeOpenAI, Llama, etc. Dependency injection makes it super clean to manage API keys, model clients, and context caching. But… I’m curious how others are structuring their projects.

Questions for you all:

  1. Are you using FastAPI for AI/ML services? If yes, what does your stack look like?

  2. Any cool tips for integrating with message queues e.g., Celery, RabbitMQ, Kafka for async task handling?

  3. What’s your take on scaling WebSockets in FastAPI for real-time AI responses?


r/FastAPI • • Dec 24 '25

Question FastAPI in 2025: Are Async & Type Hints Now Mandatory?

52 Upvotes

Building LLM backends, real-time dashboards, or AI agent APIs? Just moved a Flask/Celery setup to FastAPI. The result? One service. No Celery. 3x more WebSocket connections. Prototypes done in an afternoon. With everything moving async, is choosing a sync-first framework in 2024 just creating future tech debt?

Hot take:Ā For new Python APIs, FastAPI should be the default. Change my mind.

  • Flask/Django folks:Ā Overrated for most CRUD?

  • Anyone who bounced off:Ā What was the dealbreaker?

  • Killer feature?Ā (Pydantic + auto-docs for me).


r/FastAPI • • Sep 17 '25

Question Which ORM do you use in FastAPI?

52 Upvotes

Which ORM do you usually use in Fastapi which gives you all the things you needed out of the box and just work great?


r/FastAPI • • Jul 01 '24

Question A good FastAPI template?

52 Upvotes

I'm looking for some inspiration for best practices in FastAPI. I have my own template, but I want to see how it compares to what others have created and made available. I use Beanie, if that matters.

Any recommendations? Are there many even out there? I can always make mine public if the ecosystem is a little dry, otherwise, it'd be cool to see how others are structuring their apps.


r/FastAPI • • Sep 10 '21

Tutorial FastAPI with Async SQLAlchemy, SQLModel, and Alembic

Thumbnail
testdriven.io
52 Upvotes

r/FastAPI • • Dec 29 '25

Question FastAPI and HTMX Are We Seeing the Next Big Shift in Full-Stack Python?

51 Upvotes

Hey r/FastAPI,

I’ve been noticing something lately HTMX is blowing up.
It feels like the frontend world is pushing back against heavy JavaScript frameworks, and a lot of devs are leaning into simple, server-driven frontends again. That got me thinking:Ā Is FastAPI + HTMX becoming the modern, Pythonic answer to full-stack development?

Think about it:

  • FastAPI handles the backend with insane speed (thanks to async and ASGI).

  • HTMX handles the frontend by swapping HTML over the wire no massive JS bundles.

  • You write mostly Python, sprinkle minimal JS when needed, and still get reactive, dynamic interfaces.

  • Deployment stays simple. It’s just… HTTP.

It feels like the perfect stack for building fast, maintainable, andĀ simpleĀ web apps without drowning in tooling. I recently rebuilt a small project with FastAPI + HTMX after doing it in React + FastAPI before. The difference in complexity was staggering. Fewer moving parts, faster iterations, and the performance was

So I’m curious:

  • Is anyone else using FastAPI with HTMX (or similar libraries like Alpine.js)?

  • Are we at the start of a quiet revolution in full-stack Python?

  • Or is this just a niche trend that’ll fade?

If you’ve tried it, share your experience


r/FastAPI • • Nov 18 '25

Tutorial FastAPI-NiceGUI-Template: A full-stack project starter for Python developers to avoid JS overhead.

51 Upvotes

This is a reusable project template for building modern, full-stack web applications entirely in Python, with a focus on rapid development for demos and internal tools.

What My Project Does

The template provides a complete, pre-configured application foundation using a modern Python stack. It includes:

  • Backend Framework: FastAPI (ASGI, async, Pydantic validation)

  • Frontend Framework: NiceGUI (component-based, server-side UI)

  • Database: PostgreSQL (managed with Docker Compose)

  • ORM: SQLModel (combines SQLAlchemy + Pydantic)

  • Authentication: JWT token-based security with pre-built logic.

  • Core Functionality:

    • Full CRUD API for items.

    • User management with role-based access (Standard User vs. Superuser).

    • Dynamic UI that adapts based on the logged-in user's permissions.

    • Automatic API documentation via Swagger UI and ReDoc.

The project is structured with a clean separation between backend and frontend code, making it easy to navigate and build upon.

Target Audience

This template is intended for Python developers who:

  • Need to build web applications with interactive UIs but want to stay within the Python ecosystem.

  • Are building internal tools, administrative dashboards, or data-heavy applications.

  • Want to quickly create prototypes, MVPs, or demos for ML/data science projects.

It's currently a well-structured starting point. While it can be extended for production, it's best suited for developers who value rapid development and a single-language stack over the complexities of a decoupled frontend for these specific use cases.

Comparison

  • vs. FastAPI + JS Frontend (React/Vue): This stack is the industry standard for complex, public-facing applications. The primary difference is that this template eliminates the Node.js toolchain and build process. It's designed for efficiency when a separate JS frontend is overkill.

  • vs. Streamlit/Dash: These are excellent for creating linear, data-centric dashboards. This template's use of NiceGUI provides more granular control over page layout and component placement, making it better for building applications with a more traditional, multi-page web structure and complex, non-linear user workflows.

  • vs. Django/Flask (with Jinja templates): Django is a mature, "batteries-included" framework. This template offers a more modern, async-first approach with FastAPI, leverages Python's type hinting for robust data validation via Pydantic, and uses a live, interactive UI library (NiceGUI) instead of traditional server-side HTML templating.

Source & Blog

The project is stable and ready to be used as a starter. Feedback, issues, and contributions are very welcome.


r/FastAPI • • Sep 15 '25

pip package AuthTuna: A production-ready, async security framework with advanced session management for FastAPI

51 Upvotes

Hey everyone,

I built an async security library for FastAPI called AuthTuna to solve some problems I was facing with existing tools.

What My Project Does

AuthTuna is an async-first security library for FastAPI. It's not just a set of helpers; it's a complete foundation for authentication, authorization, and session management. Out of the box, it gives you:

  • Fully async operations built on SQLAlchemy 2.0.

  • Hierarchical RBAC for complex, nested permissions (e.g., Organization -> Project -> Resource), which goes beyond simple roles.

  • Secure, server-side sessions with built-in hijack detection.

  • A familiar developer experience using standard FastAPI Depends and Pydantic models.

Target Audience

This is built for Python developers using FastAPI to create production-grade applications. It's specifically useful for projects that need more complex, granular authorization logic, like multi-tenant SaaS platforms, internal dashboards, or any app where users have different levels of access to specific resources. It is not a toy project and is running in our own production environment.

Comparison

I built this because I needed a specific combination of features that I couldn't find together in other libraries.

  • vs. FastAPI's built-in tools: The built-in security utilities are great low-level primitives. AuthTuna is a higher-level, "batteries-included" framework. You get pre-built user flows, session management, and a full permission system instead of having to build them yourself on top of the primitives.

  • vs. FastAPI-Users: FastAPI-Users is an excellent, popular library. AuthTuna differs mainly in its focus on hierarchical permissions and its session model. If you need to model complex, multi-level access rules (not just "admin" or "user") and prefer the security model of stateful, server-side sessions over stateless JWTs, then AuthTuna is a better fit.

The code is up on GitHub, and feedback is welcome.

GitHub: https://github.com/shashstormer/authtuna


r/FastAPI • • Jul 17 '24

Other FastAPI, HTMX and Alpine JS

51 Upvotes

Hey, fellow developers!

I started with the intention of trying HTMX but ended up expanding the project to achieve a comprehensive BoilerPlate implementation. My objective was to create a robust web application boilerplate that combines the power of šŸ“Œ FastAPI, HTMX, and AlpineJS. It's designed for rapid prototyping and development, with built-in user management, roles, groups, and CRUD operations.

šŸ”— GitHub Repository: https://github.com/Hybridhash/FastAPI-HTMX

šŸ›  Key Features:

  • User Authentication and Authorization

  • Role and Group Management

  • Dashboard for User, User Profile, Role, and Group Management

  • RESTful API Endpoints for CRUD Operations

  • HTML Templates with HTMX for Dynamic Content

  • Database Migrations with Alembic

If you find this useful, please give it a ⭐ on GitHub!

Happy coding! šŸŽ‰


r/FastAPI • • Jun 15 '22

Announcement New Rule: Tutorial posts where someone is using FastAPI without transferring any knowledge is not tutorial.

51 Upvotes

This subreddit is recently flooded with "tutorials" that are using FastAPI in the examples, but that's that. There's no "knowledge transfer" whatsoever. If you run into such a post, please mark it as spam. It's mostly self-promoting content without any value, especially in regards to FastAPI.

Thanks.


r/FastAPI • • Jan 06 '21

Announcement 1k FastAPI fans!

51 Upvotes

Hey guys,

I started this subreddit because there was none before. As it's gaining some traction I plan to add some flairs etc in the near future and spend some time moderating.

Let me know if you want something specific from this subreddit. So far it was only a simple QA and knowledge sharing.

The community is rather active. Thank you for answering other users questions.

If there are any FastAPI maintainers here I will be happy to make you a mod. Just reach out to me.

And last but not least, remember that FastAPI is built on Starlette. So shout out to Tiangolo and Encode team!

Happy coding!


r/FastAPI • • Jun 20 '25

Tutorial Real-Time Notifications in Python using FastAPI + Server-Sent Events (SSE)

50 Upvotes

I recently wrote a detailed Medium article on building real-time notification systems using Server-Sent Events (SSE) in Python with FastAPI.

āœ… The post covers:

- When to use SSE vs WebSockets

- How SSE works under the hood

- FastAPI Implementation using `StreamingResponse`

- Redis pub/sub integration

- Production tips and gotchas

- Full working GitHub example

šŸ‘‰ Read here: https://medium.com/@inandelibas/real-time-notifications-in-python-using-sse-with-fastapi-1c8c54746eb7 Ā 

šŸ’» Code: https://github.com/inanpy/fastapi-sse-example

Would love to hear your feedback or how you've used real-time features in your own projects!


r/FastAPI • • Mar 27 '25

Question Which JWT Library Do You Use for FastAPI and Why?

50 Upvotes

Hey everyone,

I'm working on a FastAPI project and I'm looking into JWT (JSON Web Token) libraries for authentication. There are several options out there, such as pyjwt, python-jose, and fastapi-jwt-auth, and I'm curious to know which one you prefer and why.

Specifically:

  • Which package do you use for JWT authentication in FastAPI?

  • What are the advantages and drawbacks of each?

  • Do you prefer any package over the others for ease of use, performance, or flexibility?

I'd love to hear about your experiences and why you recommend one over the others.

Thanks in advance!


r/FastAPI • • Oct 17 '24

Question Looking for project's best practices

50 Upvotes

Hey guys! I'm new to FastAPI and I'm really liking it.

There's just one thing, I can't seem to find a consensus on best practices on the projects I find on Github, specially on the project structure. And most of the projects are a bit old and probably outdated.

Would really appreciate some guiding on this, and I wouldn't mind some projects links, resources, etc.

Thanks! =)

Edit: just to make it clear, the docs are great and I love them! It's more on the projects file structure side.


r/FastAPI • • Jun 06 '25

feedback request Built a FastAPI project template with JWT auth and email verification

49 Upvotes

Hey everyone, I just published a FastAPI starter template to help you launch new projects quickly using production-ready best practices.

It comes with built-in authentication, email verification, password recovery, SQLModel, PostgreSQL, and a modular architecture. The entire setup is Dockerized and uses uv for managing environments and dependencies.

It's ideal for anyone building FastAPI apps who wants a clean structure, secure auth flows, and minimal setup hassle.

GitHub: https://github.com/stevephary/fastapi-base
I’d appreciate any feedback or contributions.


r/FastAPI • • Jan 31 '25

Question Share Your FastAPI Projects you worked on

49 Upvotes

Hey,

Share the kind of FastAPI projects you worked on, whether they're personal projects or office projects. It would help people.


r/FastAPI • • Oct 05 '26

pip package Starlette-Admin 1.0 is out

48 Upvotes

Hey r/FastAPI!

I wanted to share the 1.0 release of Starlette-Admin, an open-source admin interface for Starlette and FastAPI.

This is the biggest release of the project so far. The list page has been completely reworked, and a long backlog of community-requested features and improvements has finally landed.

Some highlights:

  • New data experience: Reworked list view with advanced filtering, sorting, pagination, and inline editing.

  • Import & export: Server-side exports, import wizard with validation, and row-level error handling.

  • More extensible: Plugins, themes, custom form layouts, inline forms, storage backends, and new fields.

  • Broader support: Official support for Beanie and Tortoise ORM, plus improved security and production features.

The goal is to provide FastAPI applications with a full-featured admin interface without having to build one from scratch.

Links:

If you're building a FastAPI application and need an admin interface, I'd love to hear what you think and what you'd like to see next.


r/FastAPI • • Jun 15 '26 Bravo

pip package CRUDAuth: transport-agnostic auth for FastAPI (sessions + JWT + OAuth)

Post image
48 Upvotes

Hey everyone, I was tired of fixing auth bugs across all my deployed FastAPI apps so I extracted what I do for auth into a package.

It defaults to cookie sessions (with CSRF), and also supports JWT bearer tokens, OAuth (Google/GitHub/custom), and email flows (verify, reset, change).

Every transport resolves to the same Principal, so a route that gates on the user never cares whether the request came in via a cookie or a token. You can add bearer to a session app later without touching any of your authorization code.

It works over your own SQLAlchemy User model (or maps onto an existing table via a column map), and app policy like welcome emails or audit logging goes in hooks.

It's still moving, so bug reports and feedback are very welcome. It's not trying to replace fastapi-users or hosted things like Auth0/Clerk. It's more "the auth I kept rewriting myself".

Repo: https://github.com/benavlabs/crudauth
Docs (more coming): https://benavlabs.github.io/crudauth/

Also this will replace the auth in our FastAPI-boilerplate soon:
https://github.com/benavlabs/FastAPI-boilerplate

Hope this helps someone.


r/FastAPI • • Apr 08 '25

Question Recently got introduced to FastAPI’s BackgroundTasks - what are some other cool nuggets you found that not many people know about?

48 Upvotes

I’d love to know what else people use that could make FastAPI even more useful than it already is!


r/FastAPI • • Nov 09 '24

Tutorial FastAPI for MLOps (microservices): Integrate Docker, Poetry & Deploy to AWS EC2

48 Upvotes

Hey everyone! šŸ‘‹

I just wrote a detailed guide on how to set up aĀ FastAPIĀ project specifically forĀ MLOps. In this tutorial, I cover everything you need to know, from structuring your project to automating deployment with GitHub Actions.

Here's what you’ll learn:

  • UsingĀ FastAPIĀ to serve machine learning models as microservices

  • Managing dependencies withĀ Poetry

  • Containerizing the app withĀ Docker

  • Deploying effortlessly toĀ AWS EC2Ā using CI/CD

šŸ‘‰ Check out the full tutorial here:Ā FastAPI for MLOps: Integrate Docker, Poetry, and Deploy to AWS EC2
Github starter repository: https://github.com/ivesfurtado/mlops-fastapi-microservice

Would love to hear your thoughts, and feel free to contribute if you have any ideas for improvements!


r/FastAPI • • May 27 '25

Question Best user management service with FastAPI?

47 Upvotes

So I built auth using JWTs for protected routues. And for frontend I am using Nextjs.

The simple login flow works. Login -> verify -> tokens etc.

Now I want to implement authentication for Multi-Tenant users. Org -> groups -> sub groups -> users.

I explored clrek as an option, but it doesn't have that flexibility for rbac/abac.

Any solutions/services which you guys are using?

(Ps: I want to keep my Auth logic in backend only. I don't want to use nextAuth)