FastAPI for Beginners / Chapter 1 — Getting started (lessons 1–2) / Lesson 1

Setting up and your first endpoint

Time needed: about 5 min (estimate)

☆ Read later

You can try the opening of this lesson without an account.

FastAPI joins Starlette and Pydantic

FastAPI was not built from scratch; it is a thin layer that leaves the HTTP foundation to Starlette and type-based validation to Pydantic.

All FastAPI itself does is read the type hints on your functions and connect those two.

Learn that decomposition first and, when an error message later mentions starlette. or pydantic_core., you will immediately know which side it concerns.

Install the whole set with fastapi[standard].

Terminal

$ mkdir taskapi && cd taskapi $ python -m venv .venv $ source .venv/bin/activate # Windows: .venv\Scripts\activate $ pip install "fastapi[standard]" $ python -c "import fastapi, pydantic, starlette; print(fastapi.__version__, pydantic.VERSION, starlette.__version__)" 0.141.1 2.13.5 1.6.0

Writing three endpoints

Create a free account to keep reading

With an account you can read the rest of this lesson, take the quiz, and read every free lesson in this course. Lessons you answer correctly are recorded as complete.

Report a problem with this lesson

Log in to send a report.

Keyboard shortcuts

Keys available in a lesson
KeyAction
[ or Alt + ←Go to the previous lesson
] or Alt + →Go to the next lesson
?Open this list
EscClose this list

The keys do not work while the cursor is in a code editor or an input field.