Mastering REST APIs with FastAPI
Keep adding new skills with 10,000+ programs for $239 (usually $399). Save now.
Ask Coursera
22 reviews
Recommended experience
22 reviews
Recommended experience
What you'll learn
Build RESTful APIs with FastAPI, integrating advanced features like user authentication and async databases.
Implement comprehensive logging, testing, and debugging practices for secure and maintainable applications.
Leverage FastAPI features like background tasks for image generation and email processing.
Deploy applications to platforms like Render with continuous integration pipelines.
Skills you'll gain
Details to know
12 assignments
See how employees at top companies are mastering in-demand skills
There are 11 modules in this course
This course features Coursera Coach!
A smarter way to learn with interactive, real-time conversations that help you test your knowledge, challenge assumptions, and deepen your understanding as you progress through the course. In this comprehensive course, you'll master the art of building robust and efficient REST APIs using FastAPI, a modern, fast (high-performance) web framework for Python. You'll learn how to build an entire social media API, implement user authentication, integrate databases, manage background tasks, and deploy your applications in production. By the end of the course, you'll be able to design and deploy production-grade REST APIs with FastAPI, ensuring your skills are sharp and industry-ready. Throughout the course, you will start with foundational concepts, such as what APIs are and how REST APIs work. Then, you'll dive deeper into the FastAPI framework and how to build efficient, maintainable APIs with it. The course includes hands-on projects where you will work on creating social media API endpoints, integrating databases with FastAPI, adding logging and error tracking, handling user authentication, and working with background tasks. In addition, you will explore advanced topics such as integrating third-party services, like DeepAI for image generation, and learn how to deploy your FastAPI application to platforms like Render. With real-world projects and a focus on industry best practices, you will gain valuable experience to take into your future development work. This course is perfect for aspiring backend developers and those familiar with Python who wish to deepen their knowledge of REST API design and implementation using FastAPI.
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.
What's included
4 videos1 reading
4 videosβ’Total 23 minutes
- Communityβ’1 minute
- Welcome to this course!β’3 minutes
- What is an API?β’10 minutes
- What is REST?β’9 minutes
1 readingβ’Total 10 minutes
- Full Course Resourceβ’10 minutes
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.
What's included
7 videos1 assignment
7 videosβ’Total 45 minutes
- Introduction to this sectionβ’3 minutes
- Your First FastAPI Appβ’4 minutes
- Initial App Setupβ’8 minutes
- Linting, formatting and sorting importsβ’6 minutes
- Our social media API: adding postsβ’11 minutes
- Splitting our API into files with APIRouterβ’2 minutes
- Adding comments to the social media APIβ’11 minutes
1 assignmentβ’Total 15 minutes
- Working with FastAPI - Assessmentβ’15 minutes
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.
What's included
6 videos1 assignment
6 videosβ’Total 36 minutes
- Introduction to the pytest sectionβ’1 minute
- The basics of pytestβ’6 minutes
- Getting started with FastAPI testsβ’8 minutes
- Creating posts in our testsβ’5 minutes
- Adding tests for postsβ’9 minutes
- Adding comments testsβ’8 minutes
1 assignmentβ’Total 15 minutes
- Introduction to pytest - Assessmentβ’15 minutes
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.
What's included
9 videos1 assignment
9 videosβ’Total 48 minutes
- Introduction to working with databasesβ’1 minute
- Installing requirements for async databases in FastAPIβ’2 minutes
- Creating a config file using Pydanticβ’3 minutes
- Different configurations per environmentβ’6 minutes
- Config caching and how to get the config objectβ’4 minutes
- Async database setup with FastAPIβ’8 minutes
- Database connection with lifespan events in FastAPIβ’5 minutes
- Run your FastAPI test in 'test' modeβ’2 minutes
- Using a database in our FastAPI routerβ’16 minutes
1 assignmentβ’Total 15 minutes
- Working with async databases - Assessmentβ’15 minutes
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.
What's included
14 videos1 assignment
14 videosβ’Total 86 minutes
- Introduction to loggingβ’1 minute
- Python logging: loggers, handlers, and formattersβ’16 minutes
- Logger hierarchies and nameβ’8 minutes
- Adding Logging Configuration for FastAPI Applicationsβ’11 minutes
- How to configure multiple loggers in the logging moduleβ’4 minutes
- Adding File Handlers for Saving Logsβ’8 minutes
- Add logging to your FastAPI endpointsβ’7 minutes
- Python logging: filters and custom filtersβ’5 minutes
- Logging HTTPExceptions with an Exception Handlerβ’3 minutes
- Identifying logs from the same request: Correlation IDβ’7 minutes
- Adding JSON-formatted log filesβ’3 minutes
- Obfuscating email addresses in logs using a custom filterβ’9 minutes
- Adding Logtail for Cloud Logging in FastAPIβ’4 minutes
- Enabling Logtail only in productionβ’1 minute
1 assignmentβ’Total 15 minutes
- Logging in FastAPI applications - Assessmentβ’15 minutes
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.
What's included
12 videos1 assignment
12 videosβ’Total 78 minutes
- Introduction to user authenticationβ’1 minute
- Installing requirements and, what are JWTs?β’7 minutes
- Adding a users table and retrieving users by emailβ’3 minutes
- Adding user registration and testsβ’11 minutes
- Adding tests for the user registration endpointβ’3 minutes
- How to hash passwords with passlibβ’6 minutes
- Generate the access tokenβ’13 minutes
- Retrieve the current user with their tokenβ’7 minutes
- Use the current user in the API routerβ’14 minutes
- Dependency injection: getting the userβ’4 minutes
- Adding user relationships to other tablesβ’3 minutes
- (Optional) OAuth Password Bearer and Swagger Authβ’5 minutes
1 assignmentβ’Total 15 minutes
- User authentication with FastAPI - Assessmentβ’15 minutes
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.
What's included
4 videos1 assignment
4 videosβ’Total 34 minutes
- Adding a table for post likesβ’1 minute
- Adding an API route to like postsβ’7 minutes
- Extracting reusable queries with SQLAlchemyβ’8 minutes
- Query string arguments and data sorting with Enumβ’17 minutes
1 assignmentβ’Total 15 minutes
- Many-to-many relationships - Assessmentβ’15 minutes
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.
What's included
8 videos1 assignment
8 videosβ’Total 65 minutes
- Creating the confirmation tokenβ’7 minutes
- Decoding the confirmation tokenβ’15 minutes
- Adding a user confirmation endpointβ’10 minutes
- Requiring user confirmation for authenticated requestsβ’4 minutes
- Mailgun set-up and configurationβ’3 minutes
- Sending emails and testing with Pythonβ’16 minutes
- Sending a confirmation email on registrationβ’5 minutes
- Sending emails with background tasksβ’6 minutes
1 assignmentβ’Total 15 minutes
- User email confirmation - Assessmentβ’15 minutes
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.
What's included
4 videos1 assignment
4 videosβ’Total 39 minutes
- Our configuration for Backblaze B2β’1 minute
- Internal library for Backblaze B2β’10 minutes
- Writing our file upload endpointβ’9 minutes
- Writing tests for file uploadβ’18 minutes
1 assignmentβ’Total 15 minutes
- File Uploads with FastAPI - Assessmentβ’15 minutes
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.
What's included
4 videos1 assignment
4 videosβ’Total 34 minutes
- Model and database changes for image generationβ’3 minutes
- Configuration for DeepAI, our third-party serviceβ’4 minutes
- Generating images using background tasksβ’21 minutes
- Executing image generation in our FastAPI endpointβ’7 minutes
1 assignmentβ’Total 15 minutes
- Background Tasks for Image Generation - Assessmentβ’15 minutes
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.
What's included
5 videos3 assignments
5 videosβ’Total 38 minutes
- Updating our project to Pydantic v2β’6 minutes
- Deploy a FastAPI app to Renderβ’6 minutes
- Add a free PostgreSQL database to your FastAPI appβ’9 minutes
- Error management with Sentry for FastAPI appsβ’8 minutes
- Continuous Integration with GitHub Actions for Python appsβ’8 minutes
3 assignmentsβ’Total 90 minutes
- FastAPI Deployments and Application Management - Assessmentβ’15 minutes
- Full Course Assessmentβ’60 minutes
- Full Course Practice Assessmentβ’15 minutes
Instructor
Offered by
Explore more from Software Development
- Status: Free Trial
- Status: Free Trial
Specialization
- D
Duke University
Guided Project
Why people choose Coursera for their career
Frequently asked questions
Yes, you can preview the first video and view the syllabus before you enroll. You must purchase the course to access content not included in the preview.
If you decide to enroll in the course before the session start date, you will have access to all of the lecture videos and readings for the course. Youβll be able to submit assignments once the session starts.
Once you enroll and your session begins, you will have access to all videos and other resources, including reading items and the course discussion forum. Youβll be able to view and submit practice assessments, and complete required graded assignments to earn a grade and a Course Certificate.
More questions
Financial aid available,
