Community Data Science Course (Spring 2023)/Week 4 coding challenges
From CommunityData
Learning a new API
In this exercise, I want to you to practice learning to use a new API and practice reading some API documentation. We're going to start with the Dog API which is online at: https://dogapi.dog
- Visit the Dog API website and read the API documentation
- Write a URL that will return a dog fact
- Write a single URL that will return 5 dog facts
- Take your code to request a single dog fact and put into a Python program that uses
requests.get()
and passes in parameters with theparams=
argument. - Finally, write a for loop that gets 5 sets of facts 5 times (you can just try something like
for number in [1,2,3,4,5]
, downloads the lists of dog facts, and then writes out a new tab-separated values (TSV) file with columns: (1) ID of the dog fact, and (2) the fact itself!