A Taste of Web APIs
Try the other side of a web API: answering requests instead of sending them. You'll write a FastAPI app for a book club with a route that lists its books and one that finds a book by number, open the documentation FastAPI writes for you, and test both routes with pytest. The course then closes with your final capstone and where to go next.
Updated
FastAPI, a First Look
- Your First FastAPI Route (Apprentice): FastAPI turns Python functions into a web API, where a decorator ties each function to an address, a path parameter with a type hint reads part of the address, HTTPException answers 404, fastapi dev runs the app, and /docs lets you try every route.
- Testing a Route (Apprentice): FastAPI's TestClient sends requests straight to your app with no server running, so pytest tests can check each route's status code and the JSON it answers with, including the 404 for an item that isn't there, every time the code changes.
Exercise: Book Club's First Route
- Exercise: Book Club's First Route (Apprentice): Write a book club's first FastAPI app, a route that lists every book and a route that finds one book by its number or answers 404, then write two TestClient tests of your own and let pytest check it all.
Where to Go Next
- Where to Go Next (Apprentice): Look back at everything this course taught you, plan a Python tool of your own that puts it all to work, and pick the habits and the next steps that keep your Python growing.