COURSE / REAL PRACTICE
A real API client
Build a bounded Python CLI client against a bundled loopback API: validated pages, retries, cancellation and a deterministic report.
Read the explanation and diagrams, then work through the practice. Your browser profile supplies your saved progress.
What you’ll work toward
Fetch paginated order fixtures from a real local HTTP server, validate every response and export a deterministic category report. Hosted exercises inject exchanges; real network work runs only in the downloadable loopback lab.
Read an explanation, inspect the diagrams and work through the available checks, debugging exercises and builds. Feedback and prerequisite links guide the next step.
Before you start
This course builds on these skills:
- Capstone: a deterministic API client policy
- JSONL, schemas & command-line boundaries
- Exceptions, resources & honest failures
Individual lessons can add prerequisites. Your lesson progress shows your actual readiness.
A look inside the first lesson
Construct requests without string-splicing URLs
from urllib.parse import quote, urlencode
segments = ["team/a", "orders"]
path = "/" + "/".join(quote(s,safe="") for s in segments)
query = urlencode([("tag","C++ & Python"),("tag","x/y")])
print(path)
print(query)Your lesson sequence
Follow the same units and lessons in either view. Prerequisite links and your practice progress stay with each lesson.
Requests and response boundaries
- LESSON 01.01
Construct requests without string-splicing URLs
Encode path segments and ordered query pairs, preserve repeated parameters and keep header values out of URLs.
Open lesson - LESSON 01.02
Bound response reads and always close them
Pass explicit blocking-operation timeouts, cap accepted body bytes and close resources on success or failure.
Open lesson - LESSON 01.03
Validate the page the endpoint promised
Check status, media type, UTF-8, strict JSON and the application schema before accepting data.
Open lesson
Pages, retries and concurrent work
- LESSON 02.01
Paginate without loops or conflicting duplicates
Follow opaque cursors, bound pages/items, deduplicate identical records and reject conflicting versions.
Open lesson - LESSON 02.02
Retry only an explicitly repeatable operation
Bound attempts and waits, distinguish transient failures from bad data and preserve cancellation before another request.
Open lesson - LESSON 02.03
Bound concurrent work and preserve result order
Use a fixed async worker pool, cancel and await sibling tasks on failure, and distinguish cooperative cancellation from stopping a socket.
Open lesson