Python Web APIs
Build back ends with Python and FastAPI: routes and parameters, Pydantic models that check every request, data in SQLite with hand-written SQL, sign-in with…
Updated
Module 1: Your First API
Set up Python, VS Code and Git, refresh the Python an API leans on, learn HTTP and REST in plain words, and build your first FastAPI routes with path and query parameters, a request body and the automatic docs page, then build a book club's API kept in memory.
- Getting Started with Python Web APIs (5 topics, 10 lessons)
- The Python You Need for APIs (3 topics, 7 lessons)
- HTTP and REST in Plain Words (3 topics, 5 lessons)
- FastAPI Routes and Parameters (5 topics, 7 lessons)
Module 2: Models and Validation
Make an API trust nothing: check input by hand, then with Pydantic models and field rules, read and reshape FastAPI's validation errors, choose what goes back out with response models, design create, update and delete the REST way, give every error one shape, and prove it all with pytest and TestClient. Then build a tested event sign-up API.
- Request and Response Models (3 topics, 6 lessons)
- REST Design and Errors (3 topics, 4 lessons)
- Testing an API (4 topics, 5 lessons)
Module 3: Data with SQLite
Keep an API's data in a database: tables, rows and SQL from zero with SQLite and Python's own sqlite3 module, placeholders that stop SQL injection, related tables, joins, counting and paging, then all the SQL in one data module, a connection for every request, migrations, and tests against a real, throwaway database. Then move the book club's API onto SQLite.
- SQL and SQLite from Python (3 topics, 6 lessons)
- Related Tables (3 topics, 5 lessons)
- An API Backed by SQLite (5 topics, 7 lessons)
Module 4: Users and Security
Give an API accounts it can trust: passwords hashed with Argon2, sign-up and sign-in, tokens (JWT) and session cookies and when each fits, a signed-in user from a dependency, roles and ownership, CORS, rate limits, secrets kept out of your code and the attacks to expect. Then build a community center's room bookings API with roles.
- Passwords and Signing In (3 topics, 5 lessons)
- Who May Do What (3 topics, 4 lessons)
- Hardening an API (4 topics, 6 lessons)
Module 5: Professional Python APIs
Work the way professional Python developers do: settings checked at startup, logs that help and never leak, a health check, async routes where they help and background work after the response, Ruff and mypy, tests on every push with GitHub Actions, and your API online at a link with Render. Then ship an API of your own.
- Settings, Logs and Health (3 topics, 4 lessons)
- Async Routes and Background Work (3 topics, 4 lessons)
- Code Quality and CI (3 topics, 3 lessons)
- Putting an API Online (4 topics, 5 lessons)