The Complete Guide To Pydantic Including A Full Capstone Project with FastAPI And Redis
What you'll learn Gain an in-depth understanding of what Pydantic is and how it is used
Practice defining Pydantic data models using modern type hints, custom validations, and fine-tuned configuration
Learn how to define complex, interdependent, and nested data models with Pydantic
Serialize model instances into JSON and deserialize incoming data
Practice using Pydantic in the context of building and deploying a real-world python web API
Master relevant concepts in modern python application development, like dependency management and version control
Requirements Some basic experience with python would help but is NOT required
A full-length introduction to Python is included as an optional Appendix
A general willingness to learn is the only prerequisite as all relevant concepts will be explained as and when used
Description Welcome to the best resource online for learning modern Pydantic, a data validation library that has taken the python community by storm. Pydantic is was first released in 2018 and has since become one of the most popular python libraries. It is nowadays downloaded more than 130 million times a month, and is used by some of the largest organizations out there, from the tech giants like Google, Amazon, Apple, Meta, and Netflix, to large conglomerates in various other industries, such as Starbucks, JPMorgan Chase. Oh, and yes, even NASA. There's a good reason for this. Pydantic is a powerful library that elegantly solves a very common problem in software development: data validation. Pydantic's speed, simple declarative syntax, and extensibility make it an indispensable utility in modern python development. And in this course, you will learn everything you need to know to get started with Pydantic, from the very basics of defining data models, to more advanced topics such as fields with factory defaults, creating custom model-validators, data serialization, and much more.The first part of the course will be purely about pydantic, where we explore it in isolation. You will learn:how to define data models with pydantichow to compose more complex models from simpler ones via inheritancethe foundations of type hinting in python, including enumerations, literals, and other advanced types- how to use pydantic's powerful validation systemhow to serialize and deserialize data how to extract models to schemashow to validate data against pydantic modelsThen in the second part of the course we will turn our attention to the Capstone Project, where we will use pydantic to develop and deploy a python web API that allows users to create and vote on polls. This app will use Redis as our durable key-value data store, and will be deployed to production as a serverless function. The Capstone will be developed step by step, in a series of about 30 skill challenges, where you will be asked to incrementally implement small features. This will give you the opportunity to practice what you've learned in the first part of the course, and to: get a practical feel for how Pydantic is used in real-world applications learn about modern API development with python understand what Redis is and how it can be used as a durable data storelearn about virtual environments and dependency management in pythonpractice using git and githublearn the basics of serverless computing by deploying the API as a serverless functionThe course will use the latest version of Pydantic, which leverages the power of Rust to achieve blazing fast performance. Also, if you're new to python or haven't used the used the language in a while, there's a full-featured python crash course included as an extra appendix which will get you up to speed in no time.I'm very excited to share this with you, and I look forward to seeing you in the course!
Overview Section 1: Pydantic In A Nutshell
Lecture 1 Course Resource Part 1
Lecture 2 Introduction To Pydantic
Lecture 3 Our First Pydantic Model
Lecture 4 Coercion And Strict Types
Lecture 5 More Types And Constraints
Section 2: Type Hinting Foundations
Lecture 6 Date And Time Types
Lecture 7 Lists And Nested Lists
Lecture 8 Dictionaries And Typed Key-Values
Lecture 9 Sets And Tuples
Lecture 10 Unions
Section 3: Factories, Enums, And Other Props
Lecture 11 Optional, Any And Defaults
Lecture 12 UUIDs And Default Factories
Lecture 13 Immutable Attributes
Lecture 14 Additional Properties
Lecture 15 Enumerations
Lecture 16 For Better Performance: Literals
Section 4: Custom Validators
Lecture 17 Customizing Field Validators
Lecture 18 Model-Level Validators
Lecture 19 Extra: A Closer Look At Error Objects
Section 5: Model Serialization And Deserialization
Lecture 20 Instance Serialization To Dict And JSON
Lecture 21 Field Exclusions
Lecture 22 JSON Schema
Lecture 23 Deserialization
Section 6: Capstone Project: Building A Modern Python API With Pydantic, FastAPI And Redis
Lecture 24 Course Resource Part 2
Lecture 25 Overview
Lecture 26 Creating A Virtual Environment
Lecture 27 Our First Dependencies
Lecture 28 Application Directory Structure
Lecture 29 API Hello World
Lecture 30 Defining Our First Poll Model
Lecture 31 Polls Create With Placeholders
Lecture 32 Polls In The Request Body
Lecture 33 Defining The Choice Data Model
Lecture 34 Splitting Into Read And Write Models
Lecture 35 Poll vs PollCreate
Lecture 36 Polls Should Have Between 2 and 5 Choices
Lecture 37 poll_create With Incrementing Choice Labels
Lecture 38 Creating Polls Through The API
Lecture 39 Refactoring To HTTPExceptions
Lecture 40 Conceptual Introduction To Redis: Our Key-Value Store
Lecture 41 Setting Up A Redis Instance
Lecture 42 Connecting, Saving, And Retrieving Data From Redis
Lecture 43 Refactoring Connection Parameters To Environment Variables
Lecture 44 Defining utils.py
Lecture 45 Integrating save_poll With POST /polls/create
Lecture 46 Defining And Integrating GET Poll
Lecture 47 Modular Re-organization With API Routers
Lecture 48 Application Metadata
Lecture 49 Faster Iteration With Visual HTTP Clients
Lecture 50 Voting Pydantic Data Models
Lecture 51 The Votes API Router
Lecture 52 Get Choice ID From Label
Lecture 53 Creating And Returning Vote Instances
Lecture 54 Storing And Retrieving Votes In Redis Hashsets
Lecture 55 Integrating Vote Saving With The Routes
Lecture 56 Double Voting Should Not Be Allowed
Lecture 57 Voting On Expired Polls Should Not Be Allowed
Lecture 58 Other Voting Validations
Lecture 59 Optimizing Get get_choice_id_by_label()
Lecture 60 Dependency Injecting Common Validations
Lecture 61 Get All Polls
Lecture 62 Batching Requests With .mget()
Lecture 63 Parameterizing Get Polls For Poll Status
Lecture 64 Tracking Vote Counts With Hash Increment By
Lecture 65 Displaying Vote Tallies
Lecture 66 Defining The Poll Results Pydantic Data Models
Lecture 67 Returning PollResults
Lecture 68 Deleting Poll Data
Lecture 69 Extra: Custom Exception Handlers
Lecture 70 Deployment Checklist
Lecture 71
Requirements.txt And Build Configuration
Lecture 72 Git Repository And .gitignore
Lecture 73 Pushing To GitHub
Lecture 74 Deployment
Section 7: Appendix A - Python Programming Crash Course
Lecture 75 Section Resources
Lecture 76 Data Types
Lecture 77 Variables
Lecture 78 Arithmetic And Augmented Assignment Operators
Lecture 79 Ints And Floats
Lecture 80 Booleans And Comparison Operators
Lecture 81 Strings
Lecture 82 Methods
Lecture 83 Containers I - Lists
Lecture 84 Lists vs. Strings
Lecture 85 List Methods And Functions
Lecture 86 Containers II: Tuples
Lecture 87 Containers III: Sets
Lecture 88 Containers IV: Dictionaries
Lecture 89 Dictionary Keys And Values
Lecture 90 Membership Operators
Lecture 91 Controlling Flow: if, else, And elif
Lecture 92 Truth Value Of Non-booleans
Lecture 93 For Loops
Lecture 94 The range() Immutable Sequence
Lecture 95 While Loops
Lecture 96 Break And Continue
Lecture 97 Zipping Iterables
Lecture 98 List Comprehensions
Lecture 99 Defining Functions
Lecture 100 Function Arguments: Positional vs Keyword
Lecture 101 Lambdas
Lecture 102 Importing Modules
Anyone interested in learning about Pydantic