Skip to main content
PRACTICE / APPLIED PYTHON / LESSON 04

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.

8 coding challengesReal PythonMultiple response fixturesNo live network or credentials

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.

JOELEARNS / PYTHON WORKBENCH

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.

Python 3.14 · in-browser
CHALLENGE 01 / 8 · BEGINNER

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.

EXPECTED OUTPUThttps://api.example.invalid/v1/devices?site=HQ+%26+East
script.py editableCtrl / Cmd + Enter to run
Your code is stored only in session storage when enabled. Never paste secrets. Clearing this option clears saved drafts, not the editor.
Code executes only when you choose Run or Check. No account needed.
HINTS · OPTIONAL

Try solving it before asking for help. Hints never show a completed program.

PYTHON OUTPUTReady

Your printed output and errors will appear here.

VARIABLE TRACER

Run the code, then step through the executed lines to watch variable values change.

About this environment: The Python runtime is loaded on demand from a version-pinned CDN and runs inside a sandboxed, opaque-origin browser frame. Runs have a time limit. OS/network automation is outside this introductory workbench. If your code calls input(), a response panel appears to supply text to those calls. Don't paste secrets or untrusted scripts.