Section 1: Lab: Setting Up Tools and a First API
- What FastAPI is and how it differs from Flask and Django
- Install Python 3.13 or later and create a project with uv
- Install fastapi[standard] and run with the fastapi dev command
- Explore the automatic API documentation in Swagger UI and ReDoc
- Lab: build a first API and test it with Postman or Bruno
Section 2: Routing and Receiving Input
- Declare HTTP GET, POST, PUT, PATCH and DELETE
- Receive path parameters and query strings with type hints
- Use Annotated with Path, Query and Header to validate values
- Read JSON from the HTTP body and return the right status codes
- Lab: a product API that searches and filters with query strings
Section 3: Lab: Pydantic v2 and Response Models
- Create separate models for requests and responses
- Validate data with Field, validators and types such as EmailStr
- Set response_model and return types to filter outgoing data
- Nested models, lists and optional values
- Lab: a sign-up API with a complete set of validation rules
Section 4: Error Handling, Forms and File Upload
- HTTPException and a central custom exception handler
- A consistent error response format across the system
- Receive form data and URL-encoded input
- Upload files with UploadFile, checking type and size
- Serve a static file folder for images and documents
Section 5: Lab: Structuring the Project
- Split routes across files with APIRouter, prefixes and tags
- Version the API, for example /api/v1
- Configure CORS so a frontend can call the API safely
- Read settings from a .env file with pydantic-settings
- Lab: structure the TODO project ready to connect to a database