Building APIs with FastAPI
Build JSON APIs in Python with FastAPI. Learn how HTTP works by calling real APIs, then write routes, read parameters and request bodies, validate data, and send honest status codes.
Start learning
Build real skills one lesson at a time
Explore the complete curriculum below, then start with the lesson that is right for you.
About this course
This course teaches you to build web APIs in Python with FastAPI. You'll
start on the client side, reading real responses with requests to see
what HTTP looks like. Then you'll build a server by hand to see what a
server actually does, hand the busywork to FastAPI, and grow one API until
it creates, reads, updates, and deletes data and saves it to a file. You
test every route from the built-in HTTP Client.
What you'll learn
- How HTTP requests and responses work: methods, paths, status codes, headers, and JSON
- What a Python server does underneath, by building a bare ASGI app
- Writing FastAPI routes that return JSON
- Reading path and query parameters, with type hints that convert and check them
- Accepting request bodies and validating them with Pydantic models
- Handling POST, PUT, and DELETE requests and sending honest status codes
- Adding middleware, dependencies, and an API key check
- Organizing a bigger API with routers and saving data to a JSON file
Prerequisites
- Finished Python Intermediate (opens in a new tab) or comfortable with Python functions, dictionaries, modules, exceptions, and calling an API with
requests - No experience with web servers needed
Course instructor
Brad Traversy
Founder of Traversy Media and an educator known for practical, project-focused web development courses.
Course content
Keep learning
More programming courses
Advanced course
TanStack Start Fundamentals
Take React full-stack with TanStack Start. Learn type-safe file-based routing, data loading with route loaders, URL search params, and server functions, then bring it all together in a complete full-stack project.
View courseBeginner course
JavaScript Basics
Learn the JavaScript language fundamentals (variables, types, control flow, arrays, objects, and functions) by running small programs in the console.
View courseBeginner course
JavaScript DOM
Take your JavaScript out of the console and into the browser. Select elements, respond to events, and build pages that react to the user.
View course

