We may earn an affiliate commission when you visit our partners.
Andy Bek

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.

Read more

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 pydantic

  • how to compose more complex models from simpler ones via inheritance

  • the foundations of type hinting in python, including enumerations, literals, and other advanced types-

  • how to use pydantic's powerful validation system

  • how to serialize and deserialize data

  • how to extract models to schemas

  • how to validate data against pydantic models

Then 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 store

  • learn about virtual environments and dependency management in python

  • practice using git and github

  • learn the basics of serverless computing by deploying the API as a serverless function

The 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.

Enroll now

What's inside

Learning objectives

  • 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

Syllabus

Pydantic In A Nutshell
Course Resource Part 1
Introduction To Pydantic
Our First Pydantic Model
Read more
Coercion And Strict Types
More Types And Constraints
Type Hinting Foundations
Date And Time Types
Lists And Nested Lists
Dictionaries And Typed Key-Values
Sets And Tuples
Unions
Factories, Enums, And Other Props
Optional, Any And Defaults
UUIDs And Default Factories
Immutable Attributes
Additional Properties
Enumerations
For Better Performance: Literals
Custom Validators
Customizing Field Validators
Model-Level Validators
Extra: A Closer Look At Error Objects
Model Serialization And Deserialization
Instance Serialization To Dict And JSON
Field Exclusions
JSON Schema
Deserialization
Capstone Project: Building A Modern Python API With Pydantic, FastAPI And Redis
Course Resource Part 2
Overview
Creating A Virtual Environment
Our First Dependencies
Application Directory Structure
API Hello World
Defining Our First Poll Model
Polls Create With Placeholders
Polls In The Request Body
Defining The Choice Data Model
Splitting Into Read And Write Models
Poll vs PollCreate
Polls Should Have Between 2 and 5 Choices
poll_create With Incrementing Choice Labels
Creating Polls Through The API
Refactoring To HTTPExceptions
Conceptual Introduction To Redis: Our Key-Value Store
Setting Up A Redis Instance
Connecting, Saving, And Retrieving Data From Redis
Refactoring Connection Parameters To Environment Variables
Defining utils.py
Integrating save_poll With POST /polls/create
Defining And Integrating GET Poll
Modular Re-organization With API Routers
Application Metadata
Faster Iteration With Visual HTTP Clients
Voting Pydantic Data Models
The Votes API Router
Get Choice ID From Label
Creating And Returning Vote Instances
Storing And Retrieving Votes In Redis Hashsets
Integrating Vote Saving With The Routes
Double Voting Should Not Be Allowed
Voting On Expired Polls Should Not Be Allowed
Other Voting Validations
Optimizing Get get_choice_id_by_label()
Dependency Injecting Common Validations
Get All Polls
Batching Requests With .mget()
Parameterizing Get Polls For Poll Status
Tracking Vote Counts With Hash Increment By
Displaying Vote Tallies
Defining The Poll Results Pydantic Data Models
Returning PollResults
Deleting Poll Data
Extra: Custom Exception Handlers
Deployment Checklist
Requirements.txt And Build Configuration
Git Repository And .gitignore
Pushing To GitHub
Deployment
Appendix A - Python Programming Crash Course
Section Resources
Data Types
Variables
Arithmetic And Augmented Assignment Operators
Ints And Floats
Booleans And Comparison Operators
Strings
Methods
Containers I - Lists
Lists vs. Strings
List Methods And Functions
Containers II: Tuples
Containers III: Sets
Containers IV: Dictionaries
Dictionary Keys And Values
Membership Operators
Controlling Flow: if, else, And elif
Truth Value Of Non-booleans
For Loops

Save this course

Save Learning Pydantic: Advanced Data Validation In Python to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Learning Pydantic: Advanced Data Validation In Python with these activities:
Review Python Type Hinting
Solidify your understanding of Python's type hinting system, which is fundamental to defining Pydantic models effectively.
Show steps
  • Read the official Python documentation on typing.
  • Practice using type hints in simple Python functions.
  • Experiment with different type hints like List, Dict, and Union.
Review 'Fluent Python'
Gain a deeper understanding of Python's underlying mechanisms, which will enhance your ability to use Pydantic effectively.
View Fluent Python on Amazon
Show steps
  • Read the chapters on data structures and object-oriented programming.
  • Pay close attention to the sections on type hints and data validation.
  • Try to relate the concepts in the book to Pydantic's features.
Implement Custom Validators
Sharpen your skills in creating custom validators, a crucial aspect of Pydantic for enforcing complex data constraints.
Show steps
  • Define a Pydantic model with several fields.
  • Implement custom validators for each field using different validation techniques.
  • Test your validators with various inputs to ensure they work correctly.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Write a Blog Post on Pydantic
Solidify your understanding of Pydantic by explaining its features and benefits to others in a blog post.
Show steps
  • Choose a specific aspect of Pydantic to focus on.
  • Research the topic thoroughly and gather relevant examples.
  • Write a clear and concise blog post explaining the concept.
  • Publish your blog post on a platform like Medium or your personal website.
Review 'Effective Python'
Improve your overall Python coding skills, which will enhance your ability to use Pydantic effectively and write robust applications.
View Effective Python on Amazon
Show steps
  • Read the book and take notes on the key recommendations.
  • Apply the recommendations to your Pydantic projects.
  • Refactor existing code to follow the best practices outlined in the book.
Build a Data Validation API
Apply your Pydantic knowledge to build a practical API that validates incoming data, reinforcing your understanding of real-world applications.
Show steps
  • Design the API endpoints and data models.
  • Implement the API using a framework like FastAPI or Flask.
  • Use Pydantic to validate the incoming data against your models.
  • Test the API thoroughly with various inputs.
Contribute to Pydantic
Deepen your expertise by contributing to the Pydantic open-source project, gaining insights into its inner workings and best practices.
Show steps
  • Explore the Pydantic GitHub repository and identify areas for contribution.
  • Read the contribution guidelines and set up your development environment.
  • Contribute code, documentation, or bug fixes to the project.
  • Participate in code reviews and discussions with other contributors.

Career center

Learners who complete Learning Pydantic: Advanced Data Validation In Python will develop knowledge and skills that may be useful to these careers:

Reading list

We've selected two books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Learning Pydantic: Advanced Data Validation In Python.
Offers practical advice on writing clean, efficient, and maintainable Python code. It covers a wide range of topics, including best practices for data structures, functions, and classes. While not directly related to Pydantic, it provides valuable insights into writing high-quality Python code that can be used in conjunction with Pydantic. This book is commonly used by industry professionals.
Provides a deep dive into Python's core features, including data structures and object-oriented programming. It is particularly helpful for understanding the nuances of Python's type system and how it relates to data validation. While not a Pydantic-specific book, it provides valuable context for understanding the underlying Python concepts that Pydantic builds upon. This book is more valuable as additional reading than as a current reference.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser