FastAPI is a modern, fast (high-performance) web framework for building APIs with Python 3.7+ based on standard Python type hints. It's fast because it's based on Starlette, a Python 3.6+ ASGI framework, and Pydantic, a data validation library.
Features
- Fast: FastAPI is fast because it uses Starlette and Pydantic, which are both optimized for performance.
- Easy to Use: FastAPI is easy to use and learn. It's designed to be intuitive and straightforward.
- Type Checking: FastAPI uses Python type hints for automatic request validation and serialization.
- Security: FastAPI provides security features like authentication and permissions.
- Documentation: FastAPI automatically generates interactive API documentation.
Getting Started
To get started with FastAPI, you can visit the official FastAPI documentation.
Installation
To install FastAPI, you can use pip:
pip install fastapi
Quick Start
Here's a simple example of a FastAPI application:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
To run this application, save it as main.py
and execute it with the following command:
uvicorn main:app --reload
This will start a development server on http://127.0.0.1:8000
.
Images
Here's a Golden Retriever for your enjoyment.
For more information and resources, check out our FastAPI tutorials.