← all challenges

api-client

Write a small HTTP API client class with error handling and docs

the prompt

$ cat api-client.prompt
Write a Python class `APIClient` that wraps the `requests` library for a REST API. It should: (1) accept a base_url and optional api_key in __init__, (2) have a `get(path, params=None)` method and a `post(path, data)` method, (3) raise a custom `APIError` exception with the status code and message on non-2xx responses, (4) include type hints throughout, (5) have a complete docstring on the class and each public method. Show a usage example at the bottom.

rubric

correctness

Does the class work as described? Are error cases handled? Are type hints correct?

quality

Is the code clean and well-structured? Is APIError a proper Exception subclass? Are session/connection concerns handled?

documentation

Does the class have a docstring? Do all public methods have docstrings? Is the usage example runnable?

results

Claude Haiku 4.5

2.7
correctness 1.0quality 3.0documentation 4.011073ms

# Response is cut off mid-implementation (post method incomplete, no usage example at bottom), making the code non-functional despite good structure and docstrings up to that point.