# Up Next: Professional Python APIs

Look back at what Module 4 taught you, see a project that puts all of it to work, a community center's room bookings API with members and staff, and see the gaps Module 5 closes, with settings checked at startup, logs, a health check, tests on every push and your API online at a link.

Journeyman · FastAPI · Web Development · Updated November 19, 2026

By Gregor Dzierzon

## After this lesson you can

- Describe what Module 5's settings, logs, tests on every push and hosting will add to an API built in Module 4

## Key takeaways

- After Module 4 you can hash passwords, sign people in with tokens, require a signed-in user, tell 401 from 403, check ownership, and harden an API for the open internet.
- A room bookings API with members, staff, bookings that can't overlap and every hardening step from this chapter uses everything this module taught.
- So far an API runs only on your own computer, its settings are read in scattered places, and its tests run only when you remember to run them.
- Module 5 checks every setting at startup, adds logs and a health check, runs the tests on every push with GitHub Actions, and puts the API online at a link.

At the start of this module, anyone could call your APIs and do anything. Now they have members: people who sign up, sign in, and may do only what their role allows, behind an API that gives strangers very little to work with. That's the difference between a project that runs on your laptop and one you can put in front of real people.

This lesson looks back at what you can do, shows you a project that puts it all together, and gives you a first look at Module 5, where the API leaves your computer.

## What you can do now

After Module 4, you can:

- **store passwords safely** as Argon2 hashes with pwdlib, never the passwords themselves;
- **sign people up and in**, refusing a used email with 409 and a wrong email or password with one vague 401;
- **keep people signed in** with tokens (JWT) in the `Authorization` header or with session cookies, and say when each fits;
- **require a signed-in user** with a `get_current_user` dependency, and tell 401 ("who are you?") from 403 ("I know who you are, and you can't");
- **give users roles** and check that people change only their own things, with a test for each kind of user;
- **harden an API** with CORS for its own pages, security headers, a rate limit on sign-in, secrets in `.env`, an update model that forbids extra fields, and pip-audit for its packages.

## Put it all together: a room bookings API

Here's a project that uses all of it, one you can build on your own now. A community center rents out its rooms (a dance studio, a meeting room, a kitchen), and its bookings live in a paper binder at the front desk. Build the center's API on SQLite:

- **members sign up and sign in,** with passwords hashed by pwdlib, a unique email, and a JWT in the `Authorization` header;
- **members book rooms,** and cancel only their own bookings;
- **staff add rooms and see every booking;** anyone else who tries gets 403;
- **bookings can't overlap:** a second booking for the same room at the same time gets 409;
- **it's ready for the open internet:** CORS for the center's web page, a rate limit on sign-in, and every secret from environment variables;
- **tests sign in as a member, as staff and as nobody at all,** and check every rule for each.

When it's done, you have an API where members sign in and only staff manage the rooms, one you can show a friend.

## Where it falls short

Look at where the coffee club's API reads its settings. The JWT secret comes from `auth.py`, the database file's path is typed into `database.py`, and the limit of 5 sign-ins a minute sits on a decorator. A new setting means hunting for the right file, and a missing one is found only when the code that needs it runs.

When something goes wrong, the only record is whatever scrolled past in the terminal. There's no way for anyone to ask "is the API up?" without signing in. The tests are good, but they run only when you remember to type `pytest`. And `http://127.0.0.1:8000` is your own computer's address: nobody else can open it.

## What Module 5 unlocks

Module 5 is how professionals ship:

- **Settings checked at startup** with pydantic-settings: every setting in one class, read from the environment and `.env`, with one clear error that names everything missing.
- **Logs that help and never leak:** each request's method, path, status and time, at the right level, with passwords and tokens hidden.
- **A health check** at `/health`, and code that runs when the app starts and stops.
- **Async routes where they help,** for calling other services, and work that runs after the response.
- **Ruff and mypy,** and **tests on every push** with GitHub Actions, with a green badge to prove it.
- **Your API online at a link** on Render's free tier, and an honest look at where its data lives there.

## Check yourself

2 questions to try on the lesson page.

## So what

Module 4 made your API safe to open to strangers; Module 5 makes it a real service, configured, observed, tested on every push and online for anyone to use.

## Key terms

- [Settings with pydantic-settings](https://www.ask-codey.com/glossary/settings-with-pydantic-settings)
- [Health Check](https://www.ask-codey.com/glossary/health-check-rest-api)
- [Continuous Integration](https://www.ask-codey.com/glossary/continuous-integration)
- [Deployment](https://www.ask-codey.com/glossary/deployment-web-development)

## Related

- [Keeping Secrets Out of Your Code](https://www.ask-codey.com/lessons/fastapi-security-secrets)
- [The Attacks to Expect: Injection and Mass Assignment](https://www.ask-codey.com/lessons/fastapi-security-common-attacks)
- [Exercise: Harden the Coffee Club API](https://www.ask-codey.com/lessons/exercise-fastapi-harden-the-coffee-club-api)

Source: https://www.ask-codey.com/lessons/fastapi-up-next-professional-apis
