HACKER Q&A
📣 oblio

What would you use for a Python REST API in 2022?


I've heard a lot of good things about django-rest-framework.

However:

1. I've used SQLAlchemy in the past and I liked it, and I'm not sure how well it works with Django or if the Django ORM is as powerful. Though at the end of the day I just want a simple mapper and SQL query builder, not necessarily the super high level DSL.

2. How useful is the rest of Django when only the REST API parts are needed? Is it easy to disable the unneeded parts? Is it easy to completely remove them from the distribution (primarily for security concerns)

What would you recommend for an average Python dev team?

Some of the requirements:

1. authentication/authorization with support for IdPs.

2. paging.

3. built-in security features preventing various injections and web attacks.

I know about Flask but it seems like a more barebones solution that has a longer ramp-up time, in order to find the right libraries that go together and make them work well.


  👤 techdragon Accepted Answer ✓
If your contemplating the ecosystem then Django beats Flask, the framework has the rest of the parts you haven’t even contemplated needing yet. Django Rest Framework is awesome and worth investment in learning and potentially applying… however For all internal APIs I’ve abandoned RESt, even using Django and the Django ORM I no longer use REST for internal APIs, it’s gRPC for anything internal. The simplicity is a massive win, the performance is a fantastic windfall and the ability to just “lift and shift” any code in a supported language into a load balanced GRPC API is life changing.

👤 leed25d
I like Pyramid + SQLAlchemy. Pyramid scales much better that Django or Flask and it has an active and vibrant user community.

👤 halyax
I'd recommend taking a look at AWS' serverless offerings - specifically API gateway and python lambda backend fxns. You get exactly what you need, nothing you don't and its extremely quick to get set up.

👤 reducesuffering
FastAPI is the new hotness. Would only use Django Rest Framework if you need the other things from Django like ORM, Admin, Auth, etc.

👤 fermigier
Sanic + SQLAlchemy, probably, for your use case.