- Framework: FastAPI
- Description: FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
- Features:
- Fast to code: Increase the speed to develop features by about 200% to 300%.
- Fewer bugs: Reduce about 40% of human (developer) induced errors.
- Intuitive: Great editor support. Completion everywhere. Less time debugging.
- Easy: Designed to be easy to use and learn. Less time reading docs.
- Short: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
- Robust: Get production-ready code. With automatic interactive documentation.
- Standards-based: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
- Installation:
pip install fastapi[all] - Documentation: https://fastapi.tiangolo.com/
- Example:
from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_item(item_id: int, q: str = None): return {"item_id": item_id, "q": q}
- Running the app: Use
uvicornto run the application.uvicorn main:app --reload
- Interactive API docs: Once the app is running, you can access the interactive API documentation at
http:// localhost:8000/docsorhttp://localhost:8000/redoc. - License: MIT License
Customer <-> waiter <-> chef
Client <-> server <-> application
Browser <-> FastAPI <-> Python
- APIs (Application Programming Interfaces) are essential for enabling communication between different software systems.
- They allow developers to access functionalities and data from other applications, services, or platforms without needing to understand their internal workings.