Lab 11: Web APIs

Solutions

Lab Setup

Web APIs Overview

Steps to generate a query-driven web page with results:

  1. Using the requests module, make a request for data from a web API.
  2. Convert the resulting data (a JSON string) into a dictionary, using the json module.
  3. Study the data to understand how it's structured.
  4. Iterate through the data to extract the information of interest.
  5. Fill a HTML template with the extracted information (using jinja2).
  6. View the resulting HTML page in a browser (using webbrowser).

Note: the HTML template files will render as web pages in the browser. To see the underlying HTML code, view the source code (in Chrome, View > Developer > View Source)

Table of Contents