Skip to content
DevTrail

Learn FastAPI from Basic to Advanced

Fast, modern Python APIs with automatic docs.

modules
11
topics
58
exercises
169
of practice
37 h 55 min

About this course

Build REST APIs with FastAPI: path and query parameters, request bodies with Pydantic, responses and status codes, dependency injection, databases with SQLAlchemy and PostgreSQL, authentication, testing, async and deployment.

What you'll learn

11 modules and 58 topics. Every topic has short lessons, a quiz, hands-on exercises checked in your browser, and interview questions.

  1. 1APIs and FastAPI Introduction

    HTTP and REST recap, what FastAPI is, your first app and the automatic docs.

    • HTTP and REST Recap
    • What is FastAPI?
    • Your First FastAPI App
    • Automatic Docs: /docs, /redoc and OpenAPI
    • Module 1 assessment
  2. 2Path and Query Parameters

    Path params, query params, validation and type conversion.

    • Path Parameters
    • Query Parameters
    • Predefined Values with Enums
    • Validating Path and Query Parameters
    • Module 2 assessment
  3. 3Request Bodies with Pydantic

    Pydantic models, nested models, validation and field options.

    • Request Bodies with Pydantic Models
    • Field Validation and Validators
    • Nested Models and Lists
    • Examples, model_dump and Partial Updates
    • Module 3 assessment
  4. 4Responses and Status Codes

    Response models, status codes, headers and error handling with HTTPException.

    • Response Models
    • Status Codes
    • Errors: HTTPException and Exception Handlers
    • Headers, Cookies and Custom Responses
    • Module 4 assessment
  5. 5Dependency Injection

    Depends, sub-dependencies, shared logic and testable code.

    • Dependency Injection with Depends
    • Sub-dependencies and Classes as Dependencies
    • Dependencies with yield, Routers and Global Dependencies
    • Testing with dependency_overrides
    • Module 5 assessment
  6. 6Databases with SQLAlchemy and PostgreSQL

    Engines, sessions, models, CRUD and migrations with Alembic.

    • SQLAlchemy 2.0 ORM Basics
    • One Session per Request with a yield Dependency
    • CRUD Endpoints with SQLAlchemy
    • Relationships: One-to-Many and the N+1 Problem
    • PostgreSQL in Production and Alembic Migrations
    • Module 6 assessment
  7. 7Authentication and Security

    OAuth2 password flow, password hashing, JWT and protected routes.

    • Authentication Basics and Password Hashing
    • OAuth2 Password Flow and Bearer Tokens
    • JWT Access Tokens
    • Roles, Ownership and Scopes
    • CORS and API Security Basics
    • Module 7 assessment
  8. 8Testing FastAPI

    TestClient, pytest fixtures and dependency overrides.

    • Testing FastAPI Apps: TestClient and AsyncClient
    • pytest Fixtures, Factories and Parametrize
    • Dependency Overrides: Fake Users, Databases and Services
    • Testing Validation Errors and Custom Error Formats
    • Module 8 assessment
  9. 9Async, Background Tasks and Middleware

    Async endpoints, background tasks, middleware, CORS and rate limiting.

    • async def vs def: Concurrency in FastAPI
    • Background Tasks
    • Middleware: Request IDs, Timing and Logging
    • Rate Limiting an API
    • Lifespan Events: Startup and Shutdown
    • Module 9 assessment
  10. 10Deployment

    Uvicorn/Gunicorn, Docker, configuration and production checklist.

    • Uvicorn, Workers and Health Checks
    • Settings and Environment Variables with pydantic-settings
    • Docker and Docker Compose for FastAPI
    • Production Checklist and the App Factory
    • Module 10 assessment
  11. 11FastAPI Projects

    Guided API projects from CRUD to authentication.

    • Project 1: Notes API
    • Project 2: Product Catalog with Validation
    • Project 3: Authentication API with JWT
    • Project 4: Blog API
    • Project 5: URL Shortener API