FastAPI Practice
Build production-ready APIs with FastAPI through hands-on challenges, one concept at a time.
Path Operations & Routing
Learn how FastAPI turns URLs into handlers: typing the values inside the path so conversion and rejection happen before your code runs, ordering fixed paths ahead of parameterized ones, constraining a segment to a fixed set of choices, and capturing a whole nested path in one parameter.
Typed Path Parameters
This problem covers reading the values that sit inside a web address, so a caller who puts something unexpected there is turned away before any of your code runs.
Route Order And Fixed Paths
This problem covers what happens when two addresses could both match the same request, so a page with a fixed name keeps working after a more general pattern is added beside it.
Enum Constrained Categories
This problem covers limiting part of an address to a known list of choices, so a typo is refused and told what was allowed rather than quietly answering with nothing.
Storage Browser Routes
This problem covers laying out the whole set of addresses a file browser needs, so each one reaches the handler it was meant for and none of them quietly swallows another.
Query Parameters
Learn how FastAPI reads the values that arrive in the address bar: declaring them so they convert themselves, filling in the ones a caller leaves out, putting limits on what is allowed, collecting a parameter sent more than once, and binding a public name Python cannot spell.
Optional Search Filters
This problem covers searching a store's product catalog with filters a caller may leave out, so an omitted filter falls back to a sensible default and a value that makes no sense is refused with a clear reason.
Constrained Query Rules
This problem covers checking the search values a caller sends before they are used, so a term that is too short or a page size that is too large is refused rather than obeyed.
Repeated And Aliased Parameters
This problem covers reading search options a caller may send more than once or spell with a hyphen, so repeating a filter narrows the listing by each value in turn instead of only the last.
Catalog Search Contract
This problem covers accepting a full set of search options from a caller, filling in the ones left out, refusing the ones that break a rule, and reporting back exactly which options the search ran with.
Request Body and Pydantic Models
Learn how FastAPI reads what a caller sends in the body: describing its shape as a model, giving optional parts sensible defaults, putting a rule on every field, refusing keys the model never declared, and nesting models inside each other so a mistake is reported at the exact place it happened.
Item Creation Model
This problem covers describing the shape of the data a caller may send when adding an item, so the parts they leave out get sensible values and the parts they get wrong are refused by name.
Field Constrained Order
This problem covers putting limits on each value an order carries, so a quantity, a price or a note outside what the business allows is refused before the order is ever placed.
Nested Shipment Structure
This problem covers describing data that has parts inside parts, an address and a list of parcels within one shipment, so a mistake anywhere is reported at the exact place it happened.
Booking Request Payload
This problem covers taking a booking that arrives split across the address, the query and a nested body, checking every part of it, and turning down anything that does not fit before the trip is even looked up.
Response Models and Status Codes
Learn how FastAPI shapes what leaves your API: declaring a response model so internal values never escape, answering each outcome with the code it deserves, tuning how much of a record goes on the wire, and publishing the same contract in the generated description.
Filtered User Response
This problem covers deciding which parts of a stored user are safe to hand back, so passwords and internal notes stay inside the service while callers still get the details they need.
Correct Creation Codes
This problem covers answering each request with the code its outcome deserves, so a caller can tell a newly created thing from a plain success and a removal from a thing that was never there.
Serialization Tuning
This problem covers controlling how much of a record goes onto the wire, so a listing reports only what was actually filled in and a summary reports a fixed handful of fields for everything.
Accounts API Output Contract
This problem covers settling what an accounts API puts on the wire, so a list stays lean, a single account comes back complete, every outcome carries the right code, and the values meant to stay inside never leave.
Form Data, Files & Cookies/Headers
Learn how FastAPI reads everything a request carries besides its JSON body: the fields a browser form submits, uploaded files single and many, the headers a client sends about itself, and the cookies it carries back, with each part declared so the framework converts and refuses it before your code runs.
Login Form Fields
Validated File Upload
Header And Cookie Inputs
Document Portal Intake
Error Handling
Learn how FastAPI reports what went wrong: raising a failure from deep inside a service and having it answered correctly, giving one kind of business failure its own reply in a single place, reshaping the framework's validation report into the service's own, and holding every refusal to one envelope.
Domain HTTP Exceptions
Custom Exception Handler
Reshaped Validation Errors
Payments Error Contract
About this path
This path builds APIs with FastAPI: path operations and routing, query parameters, request bodies with Pydantic models, and response models and status codes. You should be able to write basic Python, including type hints, before you start. No earlier FastAPI experience is needed. The response module is about controlling exactly what your API returns, from filtered fields to the right status codes.
Frequently asked questions
4>What will I practice in this path?
4 modules: Path Operations & Routing, Query Parameters, Request Body and Pydantic Models and Response Models and Status Codes. More modules are on the way.
>How many challenges are there, and how hard are they?
16 challenges, all easy.
>What does this path run on?
Challenges run on FastAPI 0.139 and Python 3.13.
>Do I need to install anything?
No. Every challenge runs in a browser-based IDE with everything already set up, and your code is graded automatically against a test suite.
