Exercise

Communicating with an API

Before diving into this third lesson’s concepts, make sure you remember how URLs are constructed and how to interact with web APIs, from the prerequisite course Importing Data in Python, Part 2.

The marketing team you are collaborating with has been scraping several websites for customer reviews on consumer products. The dataset is only exposed to you through an internal REST API. You would like to add that data in its entirety to the data lake and store it in a convenient way, say csv. While the data is available over the company’s internal network, you still need to supply the API key that the marketing team has created for your exploration use case: api_key: scientist007.

For technical reasons, the endpoint has been made available to you on localhost:5000. You can “browse” to it, using the well-known requests module, by calling requests.get(SOME_URL). You can authenticate to the API using your API key. Simply fill in the template URL <endpoint>/<api_key>/.

Instructions 1/3

undefined XP
    1
    2
    3
  • Fill in the correct API key.
  • Create the URL of the web API by completing the template URL above. You need to pass the endpoint first and then the API key.
  • Use that URL in the call to requests.get() so that you may see what more the API can tell you about itself.