Free through lesson 3

FastAPI for Beginners

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.

Curriculum

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.

Chapter 1 — Getting started (lessons 1–2)

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.

Chapter 2 — Requests and responses (lessons 3–6)

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.

Chapter 3 — Structure and validation (lessons 7–10)

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.

Chapter 4 — The database (lessons 11–15)

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.

Chapter 5 — Authentication and running in production (lessons 16–20)

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.