FastAPIInteractive

FastAPI Basics

Master FastAPI fundamentals step-by-step. Build your first API with clear guidance, helpful hints, and immediate feedback. Perfect for beginners!

lessons
45
level
beginner
time
42 hours
price
free
Start with First Steps

What you'll learn

  • Create a minimal FastAPI application
  • Understand the basic FastAPI structure
  • Create a simple path operation
  • Return JSON responses automatically
  • Understand what path parameters are and why they're useful
  • Create endpoints with dynamic URL paths
  • Use type hints for automatic validation
  • Handle different data types in path parameters
  • Understand what query parameters are and how they work
  • Create endpoints that accept optional query parameters
  • Set default values for query parameters
  • Use type hints for automatic query parameter validation

Lessons

Each lesson runs a real FastAPI server in the browser and grades your code against its own endpoints.

  1. 01

    First Steps

    Create your first FastAPI application following the official tutorial. Learn the simplest possible FastAPI file and understand the basic concepts.

    Read the theory
  2. 02

    Path Parameters

    Learn to create dynamic URLs that accept parameters. Build endpoints that can handle user IDs, product names, and other variable data in the URL path.

    Read the theory
  3. 03

    Query Parameters

    Learn to handle query parameters in URLs. Create flexible endpoints that accept optional parameters for filtering, pagination, and customization.

    Read the theory
  4. 04

    Request Body

    Learn to handle POST requests with data in the request body using Pydantic models. Create endpoints that can receive and validate complex data structures.

    Read the theory
  5. 05

    Query Parameters and String Validations

    Learn advanced query parameter features with validation, constraints, and metadata. Add length limits, regex patterns, and documentation to your query parameters.

    Read the theory
  6. 06

    Path Parameters and Numeric Validations

    Learn to add validation constraints to path parameters using Path(). Set numeric ranges, add documentation, and create robust path parameter validation.

    Read the theory
  7. 07

    Body - Multiple Parameters

    Master all aspects of FastAPI's Body - Multiple Parameters following the complete official tutorial. Learn to mix parameters, use multiple body params, singular values, and more.

    Read the theory
  8. 08

    Body - Fields

    Learn to add validation and metadata to Pydantic model fields using Field(). Master field-level constraints, descriptions, and advanced validation.

    Read the theory
  9. 09

    Body - Nested Models

    Master complex nested data structures with FastAPI and Pydantic. Learn to use lists, sets, nested models, and deeply nested structures for powerful APIs.

    Read the theory
  10. 10

    Extra Data Types

    Explore FastAPI's support for advanced Python data types including UUID, datetime, timedelta, bytes, Decimal, and more with automatic validation and conversion.

    Read the theory
  11. 11

    Cookie Parameters

    Learn to read and validate HTTP cookies in your FastAPI endpoints using the Cookie class.

    Read the theory
  12. 12

    Header Parameters

    Learn to read and validate HTTP headers using FastAPI's Header class. Handle common headers and custom X- headers.

    Read the theory
  13. 13

    Query Parameter Models

    Group related query parameters into a Pydantic model for cleaner code and better organization.

    Read the theory
  14. 14

    Cookie Parameter Models

    Group cookie parameters into Pydantic models for structured access to multiple cookies at once.

    Read the theory
  15. 15

    Header Parameter Models

    Group header parameters into Pydantic models for organized access to multiple headers at once.

    Read the theory
  16. 16

    Response Model - Return Type

    Learn to declare response models using return type annotations and the response_model parameter for data validation, documentation, and filtering.

    Read the theory
  17. 17

    Extra Models

    Learn to create multiple related models for different use cases, reduce code duplication through inheritance, and handle Union types for flexible responses.

    Read the theory
  18. 18

    Response Status Code

    Learn how to specify HTTP status codes for your API responses using the status_code parameter and FastAPI status constants.

    Read the theory
  19. 19

    Request Forms

    Learn how to receive form data instead of JSON using FastAPI's Form class for handling HTML form submissions.

    Read the theory
  20. 20

    Request Files

    Learn how to handle file uploads in FastAPI using File and UploadFile for receiving files from clients.

    Read the theory
  21. 21

    Request Forms and Files

    Learn to handle file uploads and form data together in a single request

    Read the theory
  22. 22

    Request Form Models

    Declare form fields as Pydantic models instead of individual Form() parameters for cleaner form handling.

    Read the theory
  23. 23

    Handling Errors

    Learn to handle errors gracefully in FastAPI using HTTPException and custom error handlers

    Read the theory
  24. 24

    Path Operation Configuration

    Learn to configure path operations with status codes, tags, descriptions, and metadata.

    Read the theory
  25. 25

    Schema Extra - Examples

    Provide example data for your API documentation using Pydantic model_config and OpenAPI examples.

    Read the theory
  26. 26

    JSON Compatible Encoder

    Learn to convert Pydantic models to JSON-compatible data for database storage using jsonable_encoder.

    Read the theory
  27. 27

    Body - Updates

    Learn how to update data using PUT for full replacement and PATCH for partial updates in FastAPI.

    Read the theory
  28. 28

    Dependencies - First Steps

    Learn FastAPI's dependency injection system to share logic and create reusable components.

    Read the theory
  29. 29

    Classes as Dependencies

    Learn how to use Python classes as dependencies for better type support and code organization.

    Read the theory
  30. 30

    Dependencies - Sub-dependencies

    Learn how to create dependencies that have sub-dependencies for arbitrarily deep dependency graphs.

    Read the theory
  31. 31

    Dependencies - Path Operation Decorators

    Learn how to add dependencies to path operation decorators without passing their return values to the function.

    Read the theory
  32. 32

    Dependencies - Global Dependencies

    Learn how to apply dependencies to all path operations in a FastAPI application globally.

    Read the theory
  33. 33

    Dependencies with Yield

    Learn to create dependencies that perform cleanup operations using yield for resource management.

    Read the theory
  34. 34

    Security - First Steps

    Implement basic OAuth2 security with FastAPI's OAuth2PasswordBearer class.

    Read the theory
  35. 35

    Security - Get Current User

    Learn how to create user models and dependencies to get the current authenticated user in FastAPI endpoints

    Read the theory
  36. 36

    Security - Simple OAuth2

    Implement OAuth2 password flow with form data authentication

    Read the theory
  37. 37

    Security - OAuth2 with JWT Tokens

    Implement secure authentication using JWT tokens with password hashing and OAuth2 Bearer authentication.

    Read the theory
  38. 38

    Middleware Basics

    Learn how to create and use middleware to process requests and responses in FastAPI applications.

    Read the theory
  39. 39

    CORS Middleware

    Learn how to handle Cross-Origin Resource Sharing in FastAPI with CORSMiddleware.

    Read the theory
  40. 40

    SQL Databases with SQLModel

    Learn to integrate SQL databases with FastAPI using SQLModel for data persistence and CRUD operations.

    Read the theory
  41. 41

    Bigger Applications - Multiple Files

    Learn to structure larger FastAPI applications using APIRouter, multiple files, and proper Python package organization.

    Read the theory
  42. 42

    Background Tasks

    Learn to run operations in the background after returning a response, perfect for tasks like sending emails or processing data.

    Read the theory
  43. 43

    Metadata and Docs URLs

    Learn to customize API metadata, documentation, and OpenAPI configuration for professional API presentation.

    Read the theory
  44. 44

    Static Files

    Learn to serve static files like HTML, CSS, and JavaScript using FastAPI's StaticFiles mount.

    Read the theory
  45. 45

    Testing

    Learn how to test FastAPI applications using TestClient for reliable and maintainable code.

    Read the theory

Other tracks