Modern web APIs with FastAPI

FastAPI turns your type hints into validation, serialisation and documentation for free. We start from a single endpoint and grow it into a complete, tested application with a database, authentication and real time, ready for production.

Duration: 3 days · Level: intermediate

For: Python developers who want to build modern, fast web APIs.

Prerequisites: solid Python; some notions of asynchronous programming are a plus.

Modern web APIs with FastAPI

Day 1 — Web APIs with FastAPI

  • FastAPI vs Flask vs Django
  • Installation and a first project
  • ASGI architecture and performance
  • Route decorators and HTTP methods
  • Path parameters and validation
  • Typed query parameters
  • Request bodies with Pydantic
  • Pydantic models: schemas, nesting and custom types
  • Serialisation and deserialisation
  • Status codes, response models, headers and cookies
  • HTTPException and custom exception handlers
  • Automatic documentation

Day 2 — Database and auth

  • SQLAlchemy with FastAPI: async configuration
  • Models and schemas
  • Sessions as dependencies
  • Transactions
  • SQLModel, by the creator of FastAPI
  • Async queries, relations and joins
  • Migrations with Alembic
  • Authentication with tokens vs cookies
  • Rate limiting
  • CORS configuration
  • CSRF protection for forms

Day 3 — Complete apps, production

  • WebSockets: real-time connections
  • Broadcasting, rooms and channels
  • Example: a chat application
  • HTML applications with Jinja2 templates
  • HTML forms
  • Task queues
  • Unit and integration tests
  • Static files
  • Going to production

Elevate Your Python Proficiency!