REST APIs & Authentication Coding Clinic.
Eight Python challenges focused on response handling, least-privilege design, redaction, transport errors, safe continuation links, throttling and an all-or-nothing multi-page inventory report. Practice genuine Python logic against fictional API responses.
Real Python, offline HTTP logic: The workbench runs Python locally in its isolated browser runtime, using injected response dictionaries and callbacks. None of these tasks makes an outgoing API request, exchanges real tokens or reads your machine's credentials. Run explores your code; Check verifies the visible example and changed fixtures.
To make actual HTTP requests to a safe test service, follow the localhost mock API assignment in the written lesson. Never paste credentials into this learning site.
Write it. Run it. Understand it.
Write real Python response-handling code with offline HTTP fixtures, safe pagination, token redaction and bounded error decisions. No network requests or credentials.
Build a properly encoded read-only URL
Implement make_devices_url(site), which builds a GET endpoint URL starting with https://api.example.invalid/v1/devices and exactly one query argument named site. Use urllib.parse.urlencode rather than manually concatenating the site string. Strip leading/trailing whitespace from site; return None for empty or non-string input. Print the URL for 'HQ & East'. Additional cases include spaces, ampersands and punctuation, and verify that parsing recovers the original site as one argument.
https://api.example.invalid/v1/devices?site=HQ+%26+EastTry solving it before asking for help. Hints never show a completed program.
Your printed output and errors will appear here.
Run the code, then step through the executed lines to watch variable values change.
