by tiangolo · 5y ago · 0 comments
Nice surprise to find this shared on HN!
It's also great to see so many products/projects and companies using it successfuly in production!
I see a bunch of questions related to "how FastAPI compares to X", FastAPI was built from the learnings from other awesome tools, and is built on top of great packages. You can read a lot more about it here: https://fastapi.tiangolo.com/alternatives/
If you have questions or problems, you can ask in GitHub issues: https://github.com/tiangolo/fastapi/issues/new/choose
There's also an official Discord chat: https://discord.gg/VQjSZaeJmf
And finally, if you use FastAPI, I would love your input in the first user survey (you could win stickers ): https://tripetto.app/run/RXZ6OLDBXX?s=hn
As a very long time Django developer I see the potential for it to finally replace Django in jamstack-type apps. But two things are direly missing for that to be the default IMO:
1. A flexible admin. Django's admin allows for super fast prototyping. I wrote an accounting/bookkeeping app recently which I used for myself, and I didn't write a UI for it at all for several months because I could just get by with the admin. (Filed two quarterlies with just the admin as UI!)
2. An ORM that is as natural as Django's. I love SQLAlchemy but its syntax is a huge turnoff. I imagine the "right solution" combines the best of both worlds; maybe some Django-like syntax wrapper around SQLAlchemy. … with typings.
What do you think, is there progress in those areas?
1. An admin UI based on OpenAPI, which makes it independent of DB.
2. A mix between Pydantic and SQLAlchemy, to use the same Pydantic model for both (I have some experiment in progress).
I just need to find the time for it all, but it's certainly planned.
I'm not if it's a good idea. If app is more complex than a TODO you end up with a few way to serialise the same DB model. You have a few schemas to update User in the DB, serlize into the queue without password etc.
SQLAlchemy + Alembic are standard because they're robust and well-know, but there are alternatives (particularly with async)[0][1][2]
For admin you can FE it with something like react-admin which has pluggable data providers, or api-admin[4]
[0] https://github.com/tortoise/tortoise-orm
An admin interface would be wonderful, but given such a heavy API focus, I find Insomnia or Postman to work well enough for those interactions, so I haven't missed it all that much.
Seconding the SQLAlchemy friction though. Built-in ORM support would really help cut down the boilerplate required to wire FastAPI/Starlette models into the database. I think django devs feel the issue more acutely since defining FastAPI objects feels so familiar to making django models. But at the end, rather than having to wire up DRF serializers and viewsets, you need to wire up the database.
One other benefit to taking a more opinionated approach to database interactions: with a sensible-defaults-but-customizable user model, FastAPI could offer token based authentication/authorization out of the box by implementing something similar to Django+DRF+Djoser endpoints
Anyway, seconding the gratitude for this wonderful project, and really looking forward to using it more!
Looks like it includes the kind of admin dashboard you'd get with Django.
An automatic admin UI based on OpenAPI is one of the plans I have for the future. :)
Out of curiosity, which part of the syntax? (Hopefully not all of it.) Personally I hate the declarative part (defining the model), but feel the query syntax is good, especially with some SQL knowledge (Django’s isn’t bad either but is too divorced to the SQL syntax to me).
P.S, if anyone is interested, it took a bit of hacking, but we managed to get two unusual things working:
1. Use MsgPack instead of JSON. It works great and wasn't too much of an effort (the existing libraries are done wrong and don't work well).
2. Use the Django ORM with FastAPI. This was quite hard to do and quite manual as the Django ORM assumes the rest of the Django stack is in use.
Etebase is open source[2], so you can just check out how it's done if you are interested. I'm also happy to help if anyone has questions.
I really hope we get a good async ORM soon. I'm currently using SQLAlchemy 1.4b1 in a side project, though the typing (and mypy plugin) are unfortunately not there.
Also had a good laugh when you posted about unrealistic job requirements awhile back [1] you know you’re doing something right when recruiters start asking for experience with your project.
[1]: https://twitter.com/tiangolo/status/1281946592459853830
There is one thing though. It sounds small, but... Docs favicon is loaded from your webserver by default. I know telemetry helps, but not disclosing it and making it difficult to remove (believe me, it took me some time to do it) leaves a bad taste. Unnecessary, I would say, as the framework is impressive otherwise... I hope you reconsider this decision.
Related issue: https://github.com/tiangolo/fastapi/issues/2518
Regardless, thank you for creating and maintaining such an useful piece of software!
Hehe, there's no telemetry at all. It just points to the same docs' favicon (that is not even measured). Just to make a simple and easy to recognize UX. The same way JS and CSS for Swagger and ReDoc come from a JS CDN instead of forcing developers to figure out a way to serve those static assets.
But anyway, if you want to remove the favicon from Swagger UI, it's also in the docs: https://fastapi.tiangolo.com/advanced/extending-openapi/#sel...
But anyway, last thing I want to do is argue - as I said, I really appreciate your work! Really big thank you! :)
The docs are here: https://fastapi.tiangolo.com/
Anyway, I'm glad FastAPI is being useful!
Until this post, I (1) was amazingly not aware of this (2) have started a side project in Django/DRF (3) am incredibly attracted by FastAPI's high-quality documentation
As it relates to the final point I would say the documentation has won me over so convincingly in just an evening's reading that I am planning to immediately rewrite the django rest framework codebase in FastAPI.
You mention "High perf" as the first claim. Are there any performance benchmarks in comparison to other frameworks? I only ask because I see FastAPI as #228 on techempower. https://www.techempower.com/benchmarks/
That said, this list looks pretty bogus anyway, many of the tools listed here are not really frameworks to begin with. uvicorn for example is an ASGI server (you can run a FastAPI application ON uvicorn) so I'm not sure how this benchmark is "comparing" uvicorn and FastAPI.
Good frameworks have tools for you when such needs arise and keep your app scalable.
The system in big part thanks to Tom Christie (https://twitter.com/starletdreaming) for creating MkDocs (the documentation system) and to Martin Donath (https://twitter.com/squidfunk) for creating the Material for MkDocs theme.
Thanks for creating this awesome framework!
Will definitely add it to my toolbox. Hope Flask will die for good.