Community Data Science Course (Spring 2023)/Week 4 coding challenges

From CommunityData
< Community Data Science Course (Spring 2023)
Revision as of 23:08, 17 April 2023 by Benjamin Mako Hill (talk | contribs) (Created page with "== 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 [https://dogapi.dog 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 th...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

  1. Visit the Dog API website and read the API documentation
  2. Write a URL that will return a dog fact
  3. Write a single URL that will return 5 dog facts
  4. Take your code to request a single dog fact and put into a Python program that uses requests.get() and passes in parameters with the params= argument.
  5. 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!