← Course Home
Module 13 · Tier 10

The Full Mock API Client

Structurally, this already IS an Okta/Slack/Google user-export script — minus swapping the mock functions for real requests calls. Ten labs pulling together everything from Tiers 1-9.

Lab 1

The Auth Header

Set os.environ["MY_API_TOKEN"] = "supersecret123" yourself, read it with get_required_env(), build the auth header with build_auth_header(). Print the header.

{'Authorization': 'Bearer supersecret123'}
Lab 2

Page One

Write fetch_page(page_number, page_size=5, users=USERS), same mock as Module 12. Call fetch_page(1). Print len(result["items"]) and result["has_more"].

5 then True
Lab 3

The Rate Limiter

Write call_with_limit(state, max_calls), same mock as Module 12. state = {"calls": 0}, call it twice with max_calls=5. Print state["calls"].

2
Lab 4

Paginate Within Budget

Write fetch_all_within_budget(max_calls) combining Labs 2-3 — paginate through everything, respecting the call budget. Call it with max_calls=10. Print len(result["items"]) and result["complete"].

12 then True
Lab 5

Flatten the Fetched Data

Write flatten_memberships(users), same mechanic as Tier 9. Flatten fetch_all_within_budget(10)'s items. Print len() of the result.

15
Lab 6

Sort the Result

Sort the flattened rows by lastName. Print the first row's last name.

Chen
Lab 7

Write the Report

Write the sorted, flattened rows to "p7_report.txt", numbered with enumerate(..., start=1), same format as Tier 9.

file written, no crash
Lab 8

Confirm the Report

Read "p7_report.txt" back. Print how many lines it has.

15
Lab 9

The Summary Line

Combine the auth token from Lab 1, the fetch from Lab 4, and the flatten from Lab 5. Print "N rows, M groups, token starts with XXXX" — never print a full token in real code, only the first 4 characters.

15 rows, 6 groups, token starts with supe
Lab 10 · Final Checkpoint

Everything, One Script

Combine every mechanic from Labs 1-9 into one script: auth header → paginated/rate-limited fetch → flatten → sort → write a numbered report → print the summary line → read the report back to confirm its line count. This is the single most complete script in Module 13.

15 rows, 6 groups, token starts with supe then 15
Now go practice

Open problems/tier10_full_mock_client.py and do all 10 problems locally. Uses fixture.py -- type it in first from DAY1_01_FIXTURE.md if it's not already in this folder. Run python check.py in problems/ to grade everything.

Module 13 complete

All 10 tiers done

Tiers 1-10: from a hardcoded onboarding message to a fully paginated, rate-limited, flattened, sorted, reported mock API client — every mechanic from Modules 1-12, proven on real problems, zero new syntax the whole way.

Structurally, Tier 10's script already IS an Okta/Slack/Google user-export tool. Module 14 swaps the mocks for real calls. ← Back to Module 13