
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Learn to build rest APIs with Flask and Python, from basics to advanced concepts, including Docker, Flask-Smorest, SQLAlchemy, authentication with refresh tokens, testing with Postman, Swagger documentation, and deployment.
Set up the essential environment to build a rest api with flask and python, including VS Code, pyenv, Postman, Docker, Git, Node, GitHub, and render.com for deployment, testing, and collaboration.
Explore core to advanced Python concepts, including variables, data types, data structures, object oriented programming, type hinting, exceptions, and mutability, reinforced by coding challenges and quizzes to sharpen problem solving.
Discover how variables act as containers for storing data in Python, created as you assign a value. See how types evolve, change, and cast, including integers, strings, and more.
Learn Python string formatting with f-strings and the format method, using placeholders and variables to generate dynamic greetings and handle missing arguments.
Explore getting user input in Python with the input function, casting strings to integers, and printing formatted results using f-strings for square calculations.
Write your first Python app by collecting user input, converting to int, and calculating days old and months old using 365 days per year and f-strings for output.
Explore python's lists, tuples, and sets, comparing mutability, ordering, and uniqueness while practicing core operations like append, remove, and add.
Explore booleans in Python, representing true or false and evaluating expressions like 1 < 5; use bool to test values such as 10, 0, and None, noting emptiness yields false.
Explore creating sets, modifying them with add, remove, and pop, and performing union, intersection, and difference on unordered, mutable collections.
Explore python conditions and if statements, covering equals, not equals, less than, less than or equal, greater than, and greater than or equal, with A and B examples.
Explore using the in keyword with if statements to check membership in a list of languages like Python, JavaScript, Java, and Go, based on user input; address case sensitivity.
Master Python loops with for loops, iterating over strings, lists, and ranges. Learn the for loop syntax, using range, and the optional else block.
Master how to use a while loop in Python to run code until a condition is met, manage a counter, and control flow with break, continue, and else blocks.
Learn how to create new lists from existing ones with Python list comprehensions, extracting odd numbers using expressions, iterations, conditions, and optional functions or lambdas.
Learn to create Python dictionaries with curly braces or dict(), access, update, and delete items by key, and use get with defaults; note that lists aren’t keys, while tuples are.
Learn to create dictionaries efficiently with dictionary comprehension, mapping keys to values from loops and items, exemplified by squaring numbers and converting prices from dollars to NPR.
Learn how to destructure and unpack values from iterables such as tuples and lists, using star to capture remaining elements and underscore to ignore items, while handling length mismatches.
Learn how to define and use functions in Python with def, distinguish library from user defined functions, and call them with parameters to return values, as in sum and print.
Define and call Python functions, passing arguments such as num1 and num2, and see how values map to parameters. A function can take any number of arguments.
Learn the difference between parameters and arguments, how to pass values as positional or keyword arguments, and how default arguments set values when nothing is passed.
Explore how a Python function returns a value with the return keyword, illustrated by summing two numbers. Learn about return types like int, and list comprehension and reusable code.
Explore Python lambda functions, also known as anonymous functions, with the syntax lambda args: expression. Learn to assign a lambda to a variable, call it with or without arguments.
Learn to unpack arguments with star args and star kwargs in Python, making functions accept any number of positional and keyword arguments, with results shown as tuples and dictionaries.
Explore object-oriented programming in Python by defining classes as blueprints, creating objects, and using attributes, methods, and constructors to model real-world entities.
Examine Python's dunder methods __str__ and __repr__, showing user-friendly vs developer-friendly object representations with built-in date examples and a simple room class.
Explore differences between instance, static, and class methods in Python, using a Calculator example to show description, a static add numbers method, and a classmethod for age from birth year.
Explore Python inheritance by comparing superclass and subclass, showing how attributes and methods pass from base class to derived classes, and how to override methods with super calls.
Learn how class composition in Python delegates salary calculation to a separate salary class, exposing an annual salary via an instance method on an employee object.
Learn how type hints in Python 3.5+ declare function input and return types with annotations, e.g., grid(name: str) -> str, while preserving dynamic typing. Follow Pep8 spacing for clarity.
Learn absolute and relative imports in Python, including packages and modules, root versus subpackages, and when to use dot notation for imports.
Master handling exceptions in Python by using try-except blocks to catch specific errors, such as zero division and index errors, and using else and finally to manage flow.
Define a custom user defined exception by creating a class that inherits from the exception class, raise it based on conditions, and handle it with try/except, in a dedicated file.
Explore Python first-class functions by treating functions as objects: assign to variables, pass as arguments, and return functions, with examples of higher-order functions and function calls.
Discover how Python decorators leverage first-class functions to take a function as an argument, define an inner function, and return a decorated function that adds behavior such as logging.
Explore python decorators using the @ syntax to decorate ordinary functions, implement a smart divide decorator for all arguments, and handle division by zero without errors.
Explore mutability in Python by distinguishing mutable and immutable types, such as integers and strings versus lists and tuples, and learn how reassignment affects memory locations.
Understand why mutable default parameters are a bad idea by examining a student class that uses an empty list for grades, leading to memory location issues.
Discover how Python's map function applies a function to each item in an iterable and returns a map object that can be converted to a list, with practical examples.
Learn how Python's filter function uses a predicate with an iterable to select items like blogs or blocks based on criteria, returning a filter object you can convert to list.
Build and deploy a Flask and Python rest API for an e-commerce app, creating shops and products, with user registration, login, JWT, and Docker deployment to render.com.
Set up a Flask project in Python by creating and activating a virtual environment, then install Flask with pip to manage dependencies for a clean, isolated development setup.
Create your first rest api by building a Flask app, defining an endpoint at / with a hello function, and running the server on port 5000.
Explore json, JavaScript object notation, for data transfer between browser and server, and use Python's json module (dumps, loads) with Flask REST APIs.
Learn to test and interact with endpoints using browser or Postman, understand API concept, and test back-end routes with Postman so you can validate JSON responses.
Build a shops resource in a flask REST API by defining routes, using get and post methods, and testing with postman, while applying 200 and 201 status codes.
Retrieve a specific shop and its products via a get endpoint using the shop name parameter, returning the shop data with status 200 or a not found message.
Explore how Docker containers differ from virtual machines, sharing the host kernel for efficient, fast, portable isolation, and learn how to build and run Docker images for Flask apps.
Build a docker image from a dockerfile, run a flask app in a container, and map port 5000 (or 5001 to avoid conflicts) to the host while testing crud endpoints.
Add dependencies and a mock database to your Flask app, update endpoints to singular shop, and scaffold environment loading with requirements.txt and python-dot-env for future SQL integration.
Build and manage a Flask API by adding endpoints to list, retrieve, create, update, and delete shops and products, with input validation and clear error messages.
Test and fix new endpoints in a dockerized Flask API by running the app, mapping ports, and validating with Postman. Rebuild images and resolve errors while managing shops and products.
Enable hot reloading and debug mode for a Flask API by building a Docker image, running a container with volume mounts, and updating dependencies via requirements.txt.
Move product resources to product.py, use a blueprint and method view for get, post, and delete on products, and register blueprint in app.py for duplicate checks and testing with Postman.
Learn how marshmallow enables simplified object serialization to validate input, deserialize to Python objects, and serialize to primitive types for APIs.
Explore implementing data validation with Marshmallow in your Flask REST API by applying product and product update schemas to incoming requests and outgoing responses, and visualize schemas via Swagger UI.
Learn how to use marshmallow schemas to serialize data and apply Flask-Smorest decorators for product and shop endpoints, including response schemas, status codes, and list handling.
Test shop and product endpoints via Postman, verify create, get, update, and delete flows, and ensure validation messages; prepare to migrate from in-memory storage to SQLAlchemy in the next section.
Explore using SQLAlchemy as an ORM with Flask to replace a dictionary database, define models, and run migrations with Alembic, while deploying via Docker.
Get started by initializing the SQLAlchemy DB and creating ProductModel and ShopModel with fields id, name, price, and shop_id for tables products and shops, using product.py and shop.py.
Establish a one-to-many relationship between shop and product using SQLAlchemy, with a foreign key, back_populates, and lazy='dynamic', and update Marshmallow schemas to handle nested data efficiently.
Configure and initialize SQLAlchemy in a Flask app by importing models and db, setting a SQLite database URL and track modifications, and creating tables within the app context.
Create and insert product and shop records into the database using SQLAlchemy in a Flask app. Handle errors with try-except, commit sessions, and manage integrity, validation, and internal server errors.
Fetch database records with SQLAlchemy by ID using model.query.get_or_404 to automatically return a 404 not found when missing, applying this to product and shop models.
Learn how to update models using SQLAlchemy in a Flask REST API, implementing a put endpoint that updates an existing product or creates a new one with proper error handling.
Fetch all products and shops by using query.all, returning a list or an empty list, and prepare for deleting products or shops in the next section.
Implement cascading deletes for a one-to-many relationship by removing a shop and automatically deleting its related products, using SQLAlchemy cascade all delete and proper relationship configuration.
Test and validate the updated rest api with an sql database by exercising shop and product endpoints via postman and swagger, ensuring correct error handling.
Learn how json web tokens enable stateless authorization by encoding header, payload, and signature, and compare jwt with session-based authentication.
Learn how to configure and integrate Flask-JWT-Extended in a Python Flask app by adding dependencies, initializing a JWT manager with a secret, and testing the endpoint via Docker and Postman.
Create a user model and user schema in the Flask app to enforce login for resources such as products and shops, and raise unauthorized errors for unauthenticated users.
Integrate a login endpoint in the Flask REST API by validating username and password, issuing a JWT access token, and handling invalid credentials to enable protected endpoints.
Protect Flask endpoints with jwt_required from flask_jwt_extended, enforce login for product and shop resources, and handle expired, invalid, and missing tokens with error callbacks.
Implement a logout endpoint that revokes the current token by adding it to a blacklist, and ensure every request using jwt checks the blacklist to protect endpoints.
Learn how to implement token refresh with Flask-JWT-Extended by creating access and refresh tokens, handling fresh token requirements, and refreshing tokens via a dedicated endpoint.
Test and validate jwt secured endpoints using Postman, including register, login, token refresh, and logout, while managing access and refresh tokens in a dockerized Flask app.
Explore Git and GitHub fundamentals, learn how distributed version control tracks changes, manage local and remote repositories, and execute basic commands like init, add, status, and commit.
Learn to manage development with git branches by creating, listing, and switching branches using git branch and git checkout, then deleting branches with git branch -D.
Learn to work with remote repositories, run git remote add origin to link your local repo to a remote on GitHub, and push, pull, fetch, and delete branches.
Master git commands to manage branches with checkout -b and switch between main and a branch. Configure user details globally or locally, and push with force when branches diverge.
Compare git rebase, merge, and squash to understand how to maintain history. Learn when to apply a linear history with rebase, preserve history with merge, or condense commits with squash.
Resolve git merge conflicts by merging a new branch into main and identifying conflicting changes. Accept both changes in VS Code or the terminal, then commit and push.
Explore how dot gitignore configures Git to ignore specific files and directories, keeping a repository clean by preventing logs, compiled artifacts, and node_modules from being tracked.
Explore using git submodules to include repositories, add and update submodules with git submodule add and git submodule update --remote, and follow tips for meaningful commits, collaboration, and fearless experimentation.
Initialize a git repository for your rest api by creating a GitHub repository, running git init, ignoring virtual environment and instance files with a .gitignore, and pushing to origin main.
Extract and run the prepared React front end for the Flask REST API, install dependencies, start the app, configure CORS for local development, and deploy via Docker.
Welcome to the top-rated Udemy course on REST API development! I'm Pratap, a software engineer, and I'm here to help you master web and REST API development using Python, Flask, and Docker.
In this comprehensive course, we will cover everything you need to know, starting with a Python refresher that will take you from the basics to advanced features. We'll then dive into creating simple, intermediate, and advanced REST APIs, complete with authentication, database handling, and more, using Flask and popular extensions like Flask-Smorest, Flask-JWT-Extended, and Flask-SQLAlchemy.
Throughout the course, we'll explore essential technologies such as Git, Postman and database, ensuring you have all the tools you need to build production-ready REST APIs. Additionally, we'll cover Docker to simplify the process of running and deploying your APIs.
By the end of this course, you'll have the skills to:
Create resource-based, production-ready REST APIs using Python, Flask, and popular extensions.
Handle secure user registration and authentication with Flask.
Efficiently store resources to a database using SQLAlchemy and Flask-SQLAlchemy.
Understand the complexities of deploying Flask REST APIs.
But first, let's understand what a REST API is.
It's an application that accepts data from clients and returns data back. For instance, it can handle user authentication by accepting a username and password and checking their validity in the database. REST APIs are commonly used by web apps and mobile apps as clients.
With the knowledge you'll gain in this course, you'll be able to develop any REST API you need for your own projects.
I take great pride in offering exceptional support and feedback to every student. I'll be available to guide you and answer any questions you may have.
Don't wait any longer; take the first step toward mastering REST API development. I look forward to seeing you inside the course!