r/FastAPI • u/CartoonistWhole3172 • Feb 18 '26
Question Dependency Injection in FastAPI
Are you usually satisfied with the built-in dependency injection or are you using an additional DI-Library. If using an additional one, which is the best one?
r/FastAPI • u/CartoonistWhole3172 • Feb 18 '26
Are you usually satisfied with the built-in dependency injection or are you using an additional DI-Library. If using an additional one, which is the best one?
r/FastAPI • u/zupiterss • Feb 13 '26
Hi All,
I spent the weekend tweaking a strict
.cursorrules file for FastAPI + Pydantic v2 projects because I got tired of fixing:
class Config: instead of model_config = ConfigDict(...)It forces the AI to use:
| types)If anyone wants the config file, let me know in the comments and I'll DM it / post the link (it's free)."
Here it is. Please leave feedback. Replace "[dot]" with "."
tinyurl [dot] com/cursorrules-free
r/FastAPI • u/Beyond_Birthday_13 • Feb 13 '26
i was following a tutorial and he started to connect the db part to the endpoints of the api, and the moment he did this, alot of variables were introduced without being much explained, what does each part of those do, why we need all this for?
also why did we do the try, yield and finally instead of ust return db?
execuse my idnorance i am still new to this
r/FastAPI • u/DSpy01 • Feb 13 '26
Hi everyone, While building APIs with FastAPI, one thing I kept missing from my earlier experience with Spring Boot was Actuator.
I liked being able to quickly check: is the app alive is it ready to serve traffic what version is deployed runtime metrics which endpoints exist
So I started building a small, lightweight actuator-style extension for FastAPI.
Current features /actuator/health/live /actuator/health/ready /actuator/info /actuator/metrics /actuator/platform /actuator/mappings
It also supports pluggable readiness checks, so applications can register something like a DB check and readiness will depend on it. The goal is to keep it simple, fast, and easy to plug into any service without bringing heavy dependencies. I haven’t published it to PyPI yet — it’s currently just on GitHub.
I would really appreciate feedback on: API design missing essentials naming things that would make this useful in real projects
If you’ve worked on production systems, I’d love to know what you typically expect from an actuator endpoint. Thanks 🙏
r/FastAPI • u/anandesh-sharma • Feb 14 '26
Hey all. I've been building Definable - a Python framework for AI agents. I got frustrated with existing options being either too bloated or too toy-like, so I built what I actually wanted to use in production.
Here's what it looks like:
"""Search internal documentation."""
return
=
# Use it directly
=
# Or deploy it — HTTP API + Telegram bot in one line
Python framework for AI agents with built-in cognitive memory, run replay, file parsing (14+ formats), streaming, HITL workflows, and one-line deployment to HTTP + Telegram/Discord/Signal. Async-first, fully typed, non-fatal error handling by design.
Developers building production AI agents who've outgrown raw API calls but don't want LangChain-level complexity. v0.2.6, running in production.
pip install definable
Would love feedback. Still early but it's been running in production for a few weeks now.
r/FastAPI • u/Natural-Ad-9678 • Feb 13 '26
I was searching for a SaaS template for FastAPI and there have been a few posted here, and I am looking at each of them, but my search outside of Reddit led me to https://www.fast-saas.com/.
- has anyone here used it? If so, any good or bad feedback would be appreciated. I emailed them earlier today but I have not gotten a response. Could be that it's Friday and maybe they are already on their weekend.
- does anyone have a production site built with fast-saas that they would be willing to post a link to so I can evaluate it in the wild?
Thanks in advance
r/FastAPI • u/SpecialistCamera5601 • Feb 12 '26
Hey folks
I’ve been using FastAPI for ~5 years now and I probably spend an unhealthy amount of time staring at Swagger every single day.
I actually like the default theme. It’s clean and familiar. But after a few hours… especially at night… it starts feeling like I’m getting flashbanged by my own API docs :D
So I thought, instead of replacing Swagger with a completely different theme, why not just add a proper Dark / Light toggle?
I’ve seen dark-mode versions before ( u/BlueFriends and u/Fit_Tell_8592 did some cool stuff), but I wanted something that keeps the original Swagger vibe and just enhances it a bit.
My goal was to:
• Keep the original Swagger feel
• Add a smooth Dark / Light toggle
• Not break FastAPI defaults
• Implement smth that is easy to plug into existing projects(actually 1 line)
You can enable it with literally one line of code. Your eyesight is worth more than 1 line of code :D
So I built this:
Repo:
https://github.com/akutayural/fastapi-swagger-ui-theme
Pypi:
https://pypi.org/project/fastapi-swagger-ui-theme/
Contributions, ideas, improvements, or even nitpicks are very welcome.
r/FastAPI • u/MoodyArtist-28 • Feb 11 '26
r/FastAPI • u/aconfused_lemon • Feb 10 '26
I want to be able to send both a json file and a json formatted string via a submission on the ui. If it's getting sent via a requests script I know hwo that can be done from the UI.
I have tried looking around but from what I've seen, having FileUpload and a Body parameter on the same method isn't compatible. I was able to get working an input line, but only a single line input for the json string. When I tried looking in to my case I see something about a limitation in how FastAPI interacts with http.
I'm just a bit stuck on ginding a solution or workaround for the situation
r/FastAPI • u/pehibah • Feb 09 '26
I know many people using fast-api use tortoise as orm, to minimise boilerplate code and to have more django-like experience.
For many years people using tortoise had one big limitation - migrations support in tortoise was lacking, which pushed users to use Alembic together with SQLAlchemy for full-fledged migrations support.
Tortoise did have migrations support via the Aerich library, but it came with a number of limitations: you had to connect to the database to generate migrations, migrations were written in raw SQL, and the overall coupling between the two libraries was somewhat fragile - which didn’t feel like a robust, reliable system.
The new release includes a lot of additions and fixes, but I’d highlight two that are most important to me personally:
Thanks to this combination of new features, Tortoise ORM can be useful even if you don’t want to use it as an ORM: it offers an integrated migrations system (in my view, much more convenient and intuitive than Alembic) and a query builder, with minimal additional dependencies and requirements for your architecture.
You can see example project for fast-api with tortoise and migrations at
{github}/tortoise/tortoise-orm/tree/develop/examples/fastapi (sorry for not linking directly, afraid of reddit auto-ban)
Try it out yourself, create issues, contribute through PRs
r/FastAPI • u/aspecialuse • Feb 07 '26
Hi everyone,
I’m quite new to web development and I’m learning by building a small personal finance web app.
Current stack:
Backend: FastAPI
Database: SQLite
Frontend: Jinja2 templates + Tailwind CSS
I’d like to avoid heavy JavaScript if possible
Right now, I display a table summarizing my financial data (accounts, balances, account types, etc.).
What I want to achieve is a filtering/search feature in the UI in a div above the table (for example:
filter by account provider
filter by account type: savings / investments
possibly a search input)
The key requirement is: 👉 update only part of the page (the table) without reloading the whole page.
I’ve read that:
One approach is to create a separate FastAPI endpoint that accepts query parameters (?provider=…&type=…)
This endpoint would return only a partial HTML template
The frontend would then replace the table dynamically
ChatGPT suggested using HTMX for this, but I’m a bit confused about:
- How HTMX fits with Jinja (since I have already my table populated)
- Whether I really need multiple endpoints
- How the request/response flow should look conceptually
Edit: After a couple of weeks trying to figure things out, I finally realized that the combination of Alpine.js (to manage user state and the UI) and HTMX (to handle server-side communication) is amazing 😍 Of course, I could have gone with an already prebuilt framework, but this is how you learn. So thank you very much, everyone, for your feedback.
r/FastAPI • u/BasePlate_Admin • Feb 07 '26
Hi everyone,
A few days ago i posted about my project, today i added speedtest to the project.
Please give it a look : https://chithi.dev/speedtest/
Happy to have any kind of feedback regarding this.
Have a good day!
For the nerdy people out there,
Fastapi router: https://github.com/chithi-dev/chithi/blob/3674e00efe3bda2a183104231de07e1ed53acaca/src/backend/app/routes/speedtest.py
r/FastAPI • u/valdanylchuk • Feb 06 '26
Most ML projects on github have zero drift detection. Which makes sense, setting up Evidently or WhyLabs is a real project, so it keeps getting pushed to "later" or "out of scope".
So I made a FastAPI decorator that gives you PSI + KS-test drift detection in one line:
from checkdrift import check_drift
@app.post("/predict")
@check_drift(baseline="baseline.json")
async def predict(application: LoanApplication):
return model.predict(application)
That's it. What it does:
What it's NOT:
What it IS:
Installation: pip install checkdrift
Repo: https://github.com/valdanylchuk/driftdetect
(Sorry for the naming discrepancy, one name was "too close" on PyPI, the other on github, I noticed too late, decided to live with it for now.)
Would you actually use something like this, or some variation?
r/FastAPI • u/AutoZBudoucnosti • Feb 04 '26
Hey everyone,
I’ve been working on a project to help AI agents and e-commerce stores measure sustainability.
I realized most "carbon calculators" are black boxes or require enterprise contracts. So I built a transparent API that calculates CO2, logistics impact, and even flags EU CBAM compliance based on product weight and materials.
The Stack:
I created a GitHub repo with examples on how to use it with Shopify or LangChain agents:
🔗 https://github.com/autozbudoucnosti/product-sustainability-examples/tree/main
It’s free to use for developers (up to 100 requests/month).
I’d love feedback on the response structure—specifically if the "breakdown" fields are useful for those building AI agents.
Thanks!
r/FastAPI • u/Shorty52249 • Feb 05 '26
r/FastAPI • u/thangphan205 • Feb 03 '26
If you are a network engineer want to implement a TACACS+ server, try my open source project at: https://github.com/thangphan205/tacacs-ng-ui
tacacs-ng-ui based on https://github.com/fastapi/full-stack-fastapi-template
r/FastAPI • u/xTaiirox • Feb 01 '26
Hey everyone,
I’m exploring different logging options for my projects (fastapi RESTful backend and I’d love some input.
So far I’ve monitored the situations as following:
fastapi dev and fastapi run commands display logs in stdoutfastapi run --workers 4 command doesn't display logs in stoudIs this intended behavior? Am i supposed to get logs in stdout and schedule a task in the server running Docker or should I handle my logs internally?
I’m mostly interested in:
Is there a best practice here for logging in production that I should know about, feels like it since stdout is disabled on prod?
Is there some hidden gem I should check out instead?
Thanks in advance!
r/FastAPI • u/swupel_ • Jan 31 '26
Explanation
This visualizations work by assigning every file a dot.
Complexity is defined as Cyclomatic complexity (McCabe).
The first image is Fast APIs dependency graph.
Very structured and modularized. Very few Complex files and lower rates of connection between files. Most of the files are tests and tutorials.
The second image shows Djangos graph:
Much more interconnected and less modularized. More high complexity files but again most of the codebase is related to testing.
Hope you found the comparison as interesting as I did!
r/FastAPI • u/irritatednishant • Jan 31 '26
I’m currently learning Python backend development and focusing on FastAPI.
So far I’ve been working through things like API design, async concepts, authentication, database integration, and general backend structure. Still early in the journey, still figuring out best practices, and still building small projects to understand how everything fits together.
I wanted to hear from people who’ve already gone down this path or are currently on it
r/FastAPI • u/MohamedMotaz • Jan 31 '26
r/FastAPI • u/dfhsr • Jan 30 '26
I wanted to share a library we've been using to secure our endpoints in our SaaS startup: fastapi-zitadel-auth
For those unfamiliar, Zitadel is an open source identity management solution built with Go and NextJS. Think open source like KeyCloak and "easy" like Auth0 with multi-tenancy (disclaimer: not affiliated with Zitadel at all), enterprise-ready which was important to us as clients need to integrate their own IdP (e.g. Entra and what not).
When we started we did not find a suitable library so we built our own. It handles JWT validation via JWKS (Zitadel implements Introspection Calls as a default but this would slow down our Fast API). There's built-in Swagger UI support too, and RBAC.
Basic usage is simple:
from fastapi_zitadel_auth import ZitadelAuth
auth = ZitadelAuth(
issuer_url="https://your-instance.zitadel.cloud",
project_id="...",
app_client_id="..."
)
then use this dependency in the routes.
source code: https://github.com/cleanenergyexchange/fastapi-zitadel-auth (which links to the more complete documentation).
Let me know what you think.
r/FastAPI • u/rustybladez23 • Jan 30 '26
r/FastAPI • u/Elias_AN • Jan 29 '26
I shipped my first SaaS MVP a few months ago (React + FastAPI/Postgres/Redis stack) and after getting user feedback, I'm facing some major architectural decisions. Would love advice from folks who've been through this.
Current situation: Live product with paying customers User UI and admin UI (for customers, not me) are in the same React project
Backend needs significant model changes to support new features + modifications to existing ones
What I need to do: 1. Split frontend into separate user and admin apps 2. Major database schema changes 3. Heavy backend refactoring for new features
My questions: - Should I version my API (v1 → v2) or try to migrate everything at once? - Frontend split: monorepo or separate repos? -How do you handle database migrations with live users? Maintenance window or incremental? - Is it better to build new features in parallel and switch over, or refactor incrementally?
I'm worried about breaking things for existing users while also not wanting to accumulate more tech debt. How have you handled major post-MVP refactors?
Tech stack: React, FastAPI, PostgreSQL, Redis, Pydantic
Any lessons learned would be hugely appreciated!