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.

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.

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.

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.

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.