1. Learn
  2. /
  3. Courses
  4. /
  5. Importing Data in Python

Connected

Exercise

Putting it all together: The Library of Congress API

To hone your API skills, you're now going to check out another API, the Library of Congress API. You're going to search the Library of Congress for all their content concerning New York City. You'll then print out the material relevant to the first entry.

Instructions

100 XP
  • Import the requests package (you're probably pretty good at this by now!).
  • Apply the json() method to the response object r and store the resulting dictionary in the variable json_data.
  • json_data['items'] is a list of items returned from your query: assign the first such item to the variable nyc_loc.
  • Hit Submit Answer to print the key-value pairs of the dictionary nyc_loc to the shell.