Introduction to FastAPI
A modern, fast, web framework for building APIs with Python 3.7+ based on standard Python type hints.
Table of contents
No headings in the article.
In this article, I will introduce you to the most trending Python framework which can primarily be used for building robust APIs.
The key features of FastAPI are:
Fast - FastAPIs performance exceeds Nodejs and Go, as it runs under the uvicorn server which is one of the most secured available servers as of now
Easy to Code - With FastAPI, creating an API is as easy and joyful as unboxing your new iPhone. An API can be written in under two minutes with FastAPI.
Automated Docs - With FastAPI, the developer need not spent time writing documentation of the APIs that were built. Because swagger docs are automatically created in detail as you keep writing APIs.
Robust - FastAPI can guarantee you a production-ready code from day one.
Short and Sweet - The minimal the code requirement, the fewer the bugs are. APIs can be strictly typed using pydantic types, which helps the creation of interactive documentation.
Standard - The API creation here follows the OpenAPI standards to be universally stable and compatible.
Steps to start with FastAPI
Let's install Python first so that FastAPI works along with it.
sudo apt update sudo apt install python3.8
Install the package manager of python, python-pip which will get us all the required libraries for our FastAPI setup
sudo apt-get install python3-pip python-dev
Now install FastAPI and all dependencies with a one-liner. This also includes the uvicorn server
pip install "fastapi[all]"
Now we are ready to use the FastAPI framework and build some lightning-fast APIs. We'll discuss how to build a standard folder structure and a set of backend APIs related to an interesting topic with FastAPI. Stay tuned!
If you would like to learn and deep dive into FastAPI refer to the following links
To learn about how to start writing your first API with fastAPI , go through the next article of this series -
"Debugging is like being the detective in a crime movie where you're also the murderer." - Filipe Fortes