Skip to main content

Resilient Mini Client

Challenge on lesson: Checkpoint: Production-Style API Client

Implement MiniClient(base_url, transport=None) with get(path) -> dict. Behavior: compose url = base_url + path; call transport(url) (None → RuntimeError 'no network in sandbox'); the response object has .status and .read() -> bytes. On 200 parse and return JSON. On 5xx/429, retry up to 3 total attempts, then raise ApiError('exhausted retries'). On other 4xx, raise ApiError immediately. Non-JSON body on 200 raises ApiError('bad body').

Difficulty: intermediate

Back to lesson: Checkpoint: Production-Style API Client