FastAPI - Getting Started
A short introduction to FastAPI, a high performance, easy to learn, fast to code, ready for production Python framework.
Hello! This article is a short introduction to FastAPI, a high-performance Python framework used to prototype fast production-ready APIs. Thanks for reading!
✨ Introduction
As posted on the official website, FastAPI key features are listed below:
- Very high performance - thanks to Starlette and Pydantic
- Fast-to-code and intuitive
- Robust - provides interactive documentation
out-of-the-box
- Standards-based - fully compatible with
OpenAPI
andJSON Schema
In other words, FastAPI helps us to code faster and easier a production-ready API with autogenerated docs.
✨ Simple FastAPI Project
FastAPI requires Python 3.6 (or above) to execute successfully. For most of the Unix environments, Python3 might be already installed. To check the version, open a terminal and type:
If the version is 3.6 or above we can move forward and create a virtual environment for our first project powered by FastAPI.
Create/activate a Virtual Environment (Unix systems)
Create/activate a Virtual Environment for Windows Systems
Install FastAPI
Create main.py
Save the file and start the project using uvicorn
At this point we should be able to visit the API in the browser:
- API Root:
http://localhost:8000
- OpenAPI Specs:
http://localhost:8000/docs
- Redoc:
http://localhost:8000/redoc
Thanks for reading! For more resources, please access:
- FastAPI - official website
- Learn FastAPI by Coding - open-source sample project