2Understanding and Using APIs
- 2.1Constructing REST API requests
Covers assembling a REST API request that accomplishes a task from the API docs: the HTTP method (GET/POST/PUT/PATCH/DELETE) and endpoint (URL), headers such as Content-Type/Accept/Authorization, query parameters, and the JSON request body, together with the Basic authentication, API key, and Bearer token (OAuth) authentication schemes, framed as the diagnosis of "does my request match what the docs demand?"
- 2.2Interpreting HTTP responses
Covers reading the parts of an API response—the status code (2xx success / 3xx redirect / 401 unauthenticated, 403 forbidden, 404 not found, 429 rate exceeded / 5xx server-side), the response headers (Content-Type, Retry-After, WWW-Authenticate, etc.), and the response body (JSON containing an error message)—and troubleshooting by isolating the cause from the triad of code + the request you sent + the docs.
- 2.3API usage patterns and constraints
Covers webhooks that push a notification from the server to the client on an event (the inverse of polling), and the constraints you inevitably meet when consuming APIs—rate limiting that caps calls per unit time (429, Retry-After, exponential backoff) and pagination that splits large data (limit/offset, cursors, next links)—framed as the judgment/diagnosis of "polling vs. webhook for this requirement" and "how to handle this 429 or truncated data."
- 2.4Comparing API styles
Covers the difference between resource-oriented, stateless REST (operating URL-addressed resources with HTTP methods) and RPC designed as a call to a procedure (function), plus choosing between synchronous (the caller waits for the response) and asynchronous (the request is merely accepted and the result returned later, 202 Accepted + polling/callback), framed as the design judgment of "which style fits this requirement and this processing time."
- 2.5Calling APIs with Python requests
Covers building a script that calls a REST API with Python's requests library—sending requests via requests.get(url, headers=, params=, auth=) / requests.post(url, json=) and reading resp.status_code (checking the code, resp.raise_for_status()), resp.json() (parsing the JSON body into a dict), and resp.headers—framed as the diagnosis/fix of "what is wrong in this requests script and why does it not behave as expected?"

