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
orrequests
.The
json
library helps us transform the API’s response into a Python object, either a dictionary or a list, with theloads
method, while thedumps
method does the opposite; transforms a Python object into a JSON formatted string.The
dumps
method ofjson
is useful if we want to visualize the response of an API in a readable way. This is achieved with theindent
argument.