How to use APIs with Python
Anatomy of a Response

The HTTP response structure mirrors that of the HTTP request. It contains:

  1. A response line (line 2), which includes the three-digit HTTP status code;

  2. A header line or lines (line 3), which include further information about the server and its response;

  3. The body (line 5 and line 6), which contains the text message of the response (for example, "404" would have "file not found" in its body).

Check out the example response in the editor. See how its structure resembles the request layout?


Header lines can contain lots of extra information. We've made a request to placekitten.com on line 10. On line 13, print the header information (which will display as a big, ugly dictionary) by calling print on the headers attribute of response.

Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

You can get the header data from response by calling its headers attribute like so:


You should print this result.