Frameworks and Tools that Inspired FastAPI
This article examines the various Python web frameworks, libraries, and standards—such as Django, Flask, Django REST Framework, Requests, Swagger/OpenAPI, Marshmallow, Pydantic, Starlette, and Uvicorn—that inspired FastAPI's design, highlighting their key features and how they contributed to FastAPI's capabilities.
Frameworks that Inspired FastAPI
Original article: https://fastapi.tiangolo.com/alternatives (author: tiangolo, creator of FastAPI). It discusses the inspirations behind FastAPI, compares it with alternative frameworks, and extracts lessons learned.
Django
Django is the most popular Python web framework, trusted for large systems like Instagram. It tightly integrates with relational databases (MySQL, PostgreSQL), making NoSQL back‑ends less straightforward.
Django REST Framework (DRF)
DRF adds flexible API building capabilities to Django and was the first framework to automatically generate API documentation, a feature that directly inspired FastAPI.
DRF’s author, Tom Christie, also created Starlette and Uvicorn, the foundations on which FastAPI is built.
Flask
Flask is a lightweight micro‑framework without built‑in database integration, offering simplicity and flexibility that allow easy use of NoSQL databases and modular extensions.
Its minimal routing system inspired FastAPI to become a micro‑framework that can mix and match tools as needed.
Requests
Requests is a widely used HTTP client library. FastAPI is not a replacement for Requests; instead, FastAPI often uses Requests internally.
Requests’ simple, intuitive design and sensible defaults influenced FastAPI’s API design.
<code>response = requests.get("http://example.com/some/url")</code>FastAPI equivalent endpoint:
<code>@app.get("/some/url")
def read_url():
return {"message": "Hello World"}</code>Both use a similar pattern: requests.get(...) vs. @app.get(...) .
Swagger / OpenAPI
DRF’s automatic API docs led to the discovery of the Swagger specification (now OpenAPI). FastAPI adopts OpenAPI to provide standardized, auto‑generated documentation with UI tools such as Swagger UI and ReDoc.
Flask REST Frameworks – Marshmallow
Marshmallow provides data serialization and validation, converting Python objects to JSON and ensuring input types are correct. FastAPI adopted a similar approach using Pydantic.
FastAPI’s Core Dependencies
Pydantic
Pydantic uses Python type hints for data validation, serialization, and JSON‑Schema generation, offering performance advantages over Marshmallow and excellent editor support.
Starlette
Starlette is a lightweight ASGI framework offering high performance, WebSocket, GraphQL, background tasks, CORS, GZip, static files, and more. FastAPI builds on Starlette, inheriting all its capabilities.
Impressive performance
WebSocket support
GraphQL support
Background task handling
Startup/shutdown events
Test client based on Requests
CORS, GZip, static files, streaming responses
Session and cookie support
100% test coverage
100% type‑annotated codebase
Zero external dependencies
Uvicorn
Uvicorn is a fast ASGI server built on uvloop and httptools. It is the recommended server for running FastAPI applications, often combined with Gunicorn for multi‑process deployments.
Overall, FastAPI combines the best ideas from these projects: automatic documentation (DRF/Swagger), simple routing (Flask/Requests), type‑driven validation (Pydantic), and high‑performance async handling (Starlette/Uvicorn).
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.