If you have read some of my previous posts on Python, you know I’m a  Flask fan, and it is my goto for building APIs in Python. However, recently I started to hear a lot about a new API framework for Python called  FastAPI, and after building some APIs with it I can say, it is amazing!

This project was created by  Sebastian Ramírez and it has accumulated at the time of writing almost 20k stars, and big names building APIs in production like Microsoft, Uber, Netflix, and others.

But why is this new library so popular and how does it compare with Flask or Django?

Features

FastAPI is a rather minimalistic framework, more of the likes of Flask. However, that doesn’t make it less powerful. FastAPI is built using modern Python concepts and it’s based out of Python 3.6 type declarations. Let’s see some of the features this library is packed with:

Automatic Docs

A must-have for any API is documentation about the endpoints and the types. A common approach to solve this problem is the use of OpenAPI and subsequently tools like Swagger UI or ReDoc to present the information. These come packed automatically with FastAPI. Allowing you to focus more on your code rather than setting up tools.

Typed Python

This is a BIG one. FastAPI makes use of Python 3.6 type declarations (thanks to Pydantic), this means that it uses a Python feature that allows you to specify the type of a variable. And this framework makes extensive use out of it, providing you with great editor support. Autocompletion works amazingly.

#python #fastapi

Quickly Develop Highly Performant APIs with FastAPI and Python
2.15 GEEK