Which Python framework is best for API-only backend: FastAPI, Django Ninja, or Django?

Hey everyone! I’m stuck choosing between FastAPI, Django Ninja, and Django for my new project. It’s a CRUD app that needs an ORM and will use LLMs for chatbots. I’m only using Python for the API layer, with Next.js on the frontend. No need for an admin panel, but I’ll be querying data from BigQuery a lot.

Here’s what’s on my mind:

  1. Django Ninja looks good, but I’m worried about its single maintainer and growing number of GitHub issues.

  2. FastAPI is cool, but I’m not sure about the maturity of its recommended ORMs compared to Django’s.

  3. Django with DRF is tried and true, but I’ve heard it might struggle with async support for LLMs and external HTTP requests.

Has anyone here used these frameworks for similar projects? What was your experience like? Any pros and cons I’m missing?

Also, I’ve seen some buzz about Litestar + SQLAlchemy. How does that stack up against the others?

Thanks for any insights you can share!

I’ve used FastAPI for similar projects and it’s been great. async support is top-notch for LLMs and HTTP requests. SQLAlchemy works well as an ORM. Django might be overkill if you don’t need the admin panel. FastAPI’s speed and simplicity make it my go-to for API-only backends. just my 2 cents!

Having worked extensively with both Django and FastAPI, I’d lean towards FastAPI for your specific use case. Its async capabilities are particularly well-suited for handling LLMs and external HTTP requests efficiently. While Django’s ORM is robust, SQLAlchemy with FastAPI provides comparable functionality and integrates seamlessly.

FastAPI’s performance and simplicity shine in API-only backends. It’s lightweight yet powerful, allowing for rapid development without sacrificing scalability. The extensive documentation and growing community support also make troubleshooting easier.

Regarding maturity concerns, FastAPI has matured significantly since its inception. It’s now widely adopted by major tech companies, which speaks to its reliability and performance in production environments.

For your CRUD app with BigQuery integration, FastAPI’s flexibility will serve you well by allowing easy implementation of custom middleware and extensions that can cater specifically to your data querying needs.

hmm, interesting question! have you considered Litestar? i’ve heard good things about it paired with SQLAlchemy. it might offer a nice balance between FastAPI’s speed and Django’s robustness. what’s your experience with async programming? that could be a factor to consider too. any thoughts on how you’ll handle authentication?