Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Coursera

Mastering REST APIs with FastAPI

Packt via Coursera

Overview

Coursera Plus Annual Sale: All Certificates & Courses 25% Off!
Embark on an immersive journey to master the art of building and deploying REST APIs with FastAPI. This comprehensive course will equip you with the knowledge and skills to create efficient, high-performance APIs that leverage the latest industry practices. Learn how to integrate asynchronous databases, implement user authentication, and manage application logging to ensure secure and scalable API solutions. Begin your journey by understanding the basics of APIs, REST principles, and FastAPI. Build your first FastAPI application and enhance it with practical features like social media posts and comments. Move deeper into essential topics like testing with pytest, logging, and handling many-to-many relationships, ensuring your applications are robust and maintainable. Explore advanced features such as working with asynchronous databases, implementing user authentication with JWTs, and enabling email confirmations. Learn how to upload files, generate images using background tasks, and deploy FastAPI applications with modern deployment platforms like Render. Discover tools like Sentry for error monitoring and GitHub Actions for CI/CD pipelines. This course is ideal for intermediate Python developers aiming to specialize in building APIs. While basic Python knowledge is necessary, the step-by-step approach ensures that you can follow along easily. If you’re passionate about creating professional-grade APIs, this course is your gateway to success.

Syllabus

  • Course Introduction
    • In this module, we will lay the foundation for your journey into mastering REST APIs with FastAPI. You will explore the importance of community in software development, gain clarity on what to expect from this course, and dive into the core concepts of APIs and REST, setting the stage for the practical lessons ahead.
  • Working with FastAPI
    • In this module, we will dive into the essentials of working with FastAPI, starting with creating your first application. You will learn how to configure a clean and maintainable setup, follow best practices for code formatting, and implement core features of a social media API. By the end of this section, you will also know how to manage a scalable codebase using APIRouter for modular development.
  • Introduction to pytest
    • In this module, we will explore pytest, a robust testing framework for Python. You will start with its basics and then focus on writing and implementing tests for your FastAPI applications. By the end of this section, you will have built a suite of tests to ensure the reliability of the posts and comments features in your API, laying the groundwork for quality assurance in your projects.
  • Working with async databases
    • In this module, we will delve into the integration of asynchronous databases with FastAPI. You will learn how to install necessary dependencies, create configuration files using Pydantic, and manage multiple environments. Additionally, you will set up an async database, handle connections using lifespan events, and integrate database operations into your API routers to enable seamless data persistence.
  • Logging in FastAPI applications
    • In this module, we will focus on implementing robust logging mechanisms in FastAPI applications. You will explore Python’s logging framework, configure multiple loggers, and add file handlers to persist logs. Advanced techniques like using filters, obfuscating sensitive data, and implementing correlation IDs will also be covered. Additionally, you’ll learn how to integrate and manage cloud-based logging tools like Logtail, enabling efficient monitoring and debugging in production.
  • User authentication with FastAPI
    • In this module, we will cover user authentication in FastAPI, from the basics of creating a users table to advanced features like token generation and password hashing. You will implement user registration, retrieve the current user using tokens, and apply dependency injection for streamlined user management. Additionally, the module explores integrating user relationships with other tables and optional features like OAuth Password Bearer and Swagger for secure and well-documented APIs.
  • Many-to-many relationships
    • In this module, we will explore the implementation of many-to-many relationships in FastAPI using SQLAlchemy. You will learn how to set up a table for post likes, create API routes for interacting with posts, and streamline database operations with reusable queries. The module also covers advanced techniques like using query string arguments and Enums to enable data sorting and filtering, enhancing the functionality and user experience of your application.
  • User email confirmation
    • In this module, we will implement user email confirmation in FastAPI. You will learn how to generate and decode confirmation tokens, create a confirmation endpoint, and enforce email verification for authenticated requests. Additionally, the module guides you through setting up Mailgun, sending confirmation emails, and optimizing email delivery using background tasks to ensure a seamless and efficient user experience.
  • File Uploads with FastAPI
    • In this module, we will focus on enabling file uploads in your FastAPI application. You'll learn how to set up and integrate Backblaze B2 as a file storage solution, implement a dedicated file upload endpoint, and write tests to ensure seamless and secure operation.
  • Background Tasks for Image Generation
    • In this module, you will learn how to implement image generation features in FastAPI using background tasks. You will modify your application’s models and databases, configure DeepAI as a third-party service, and use background tasks to optimize image generation. By the end, you will have fully integrated image generation functionality into your FastAPI endpoints.
  • FastAPI Deployments and Application Management
    • In this module, you will learn to deploy and manage FastAPI applications effectively. You will update your project to Pydantic v2, deploy your app to Render, and configure a PostgreSQL database. Additionally, the module covers integrating Sentry for error tracking and setting up GitHub Actions for continuous integration, ensuring a streamlined deployment and management process.

Taught by

Packt - Course Instructors

Reviews

Start your review of Mastering REST APIs with FastAPI

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.