Read a raw HTTP request and response and say what each part does.
Choose the right action for each group of status codes.
Read and write JSON in Python, and know what it cannot hold.
Write an HTTP client that sets a timeout, checks the status, retries only what is safe, and follows pagination.
Explain why retries need a limit, a delay and, for some requests, an idempotency key.
Why this matters for agents
Every model call is an HTTP request. Every tool that reaches an outside service is an HTTP request. These requests fail every day: rate limits, overloaded servers, slow replies. How your code handles a failure decides whether your agent recovers or crashes.
A very common interview question at this level is: how would you retry a failing HTTP call safely? This module is the answer.
How computers ask each other for things
When you open a web page, your browser asks a computer somewhere else for it, and that computer answers. Programs talk to each other the same way: your program asks a web service for weather, or sends a message to a model, and gets an answer back. The agreed set of rules for these questions and answers is called HTTP.
HTTP
The rules for how a client (the program that asks) and a server (the program that answers) exchange messages over the internet. The client sends a request; the server sends back a response. Both are plain text with a fixed layout.
API
A way for one program to ask another program for something, with agreed rules for the questions and the answers. A web API is an API you reach over HTTP, for example a weather service or a model provider.
Here is a real request and response, captured by running curl against a small test server on my own computer:
Lines starting with > are what the client sent. Lines starting with < are what the server replied. (Most real servers say HTTP/1.1 or HTTP/2 on the reply; the small test server I used says HTTP/1.0. It makes no difference to you.)
One request and one response. Everything an API does is built from these parts.
Read the request:
GET is the method: the kind of action. This one means "read".
/weather?city=Pune is the path (which thing I want) followed by a query after the ? (extra details, here the city).
Host says which server this is for. User-Agent says which program is asking. Accept says which formats are welcome. Lines like these are headers: small labelled pieces of information about the message.
Read the response:
200 OK is the status code, a number that says how it went. 200 means success.
The headers say what kind of data follows (Content-Type: application/json) and how long it is.
After the blank line comes the body: the actual data. Here it is a small piece of JSON.
Check yourself
Which part of a request says what kind of action it is? Which part says which thing?
Where in a response do you find the data, and where the outcome?
What is the difference between a client and a server?