4. Testing the University Domains API

University Domains and Names Data List & API is an API that contains domains, names, and countries of most universities around the world.

Let’s see an example of how to use this API. We will ask for universities in Turkey that have the word “middle” in their name.

Let’s find all the universities in Colombia.

4.1. Learnings

  • We access APIs to search for information that is useful for us.

  • We can request information with two Python libraries: urllib or requests.

  • The json library helps us transform the API’s response into a Python object, either a dictionary or a list, with the loads method, while the dumps method does the opposite; transforms a Python object into a JSON formatted string.

  • The dumps method of json is useful if we want to visualize the response of an API in a readable way. This is achieved with the indent argument.


    On a scale from 1 (needs improvement) to 3 (excellent), how would you rate this chapter?
  • 1
  • 2
  • 3
You have attempted of activities on this page