Skip to content

Week 12: Web APIs with FastAPI

Due: Wednesday, Nov 11th

Tuesday's class connects FastAPI to SQLModel; Thursday builds out a backend. HW6 and GP5 both depend on this material, so it is worth the full hour.

Prompt

Paste the standard prompt, then paste this block.

Topic: Serving data over a web API with FastAPI.

My learning objectives:
- Trace how an HTTP request becomes a database query and then a
  JSON response.
- Distinguish path parameters from query parameters, and say
  when each is appropriate.
- Explain what a response model declares, and why declaring one
  matters.

Show me where this lives in the documentation. Tell me what the
official docs call each thing and roughly where to find it, and
give me search terms, rather than explaining everything yourself.

Sources

  • Learn in the FastAPI documentation. Work through the first steps, path parameters, and query parameters pages of the tutorial.

Stop after query parameters. The tutorial continues well past what this course needs, and the later pages will make more sense once you have an endpoint of your own running.

Run the examples

FastAPI generates an interactive documentation page at /docs for whatever you build. Starting the example application and clicking through that page teaches more in five minutes than reading about it does.