From setting up your environment through validation from type hints, dependency injection, SQLAlchemy 2.0, authentication and authorisation, and testing, all the way to deploying to production with Docker. Twenty lessons that build one task management API from the first line to the last. Every piece of code and command output was produced by actually running Python 3.13 and FastAPI 0.141.
The 20 lessons are grouped into five chapters. Working through them in order is the best way, but you are welcome to dip into whatever interests you. Note: FastAPI cannot run inside the browser, so try everything in the project you create in lesson 1.
You create a virtual environment, stand up your first endpoint, and see how type hints become validation and documentation on their own. By the end you understand why the order you register routes in changes the result.
A full pass over the way in and the way out of an API: query parameters, bodies and responses. Finally you measure the difference between async def and def so you can decide which to write yourself.
You split main.py up, write shared logic as dependencies, and settle the shape of input checks and errors. Everything in the second half — the database, authentication and tests — sits on the foundation you build here.
You store data with SQLAlchemy 2.0 and implement CRUD, relationships, search and file attachments. For the N+1 problem, you count the actual SELECT statements to confirm it.
You add JWT authentication and authorisation, CORS, background work and tests. Finally you push configuration out into environment variables and get it production-ready with Alembic and Docker.
Once you have finished all 20 lessons, learn to run this API in a container with Docker. Membership unlocks every course.