#!/usr/bin/env python # coding: utf-8 # --- # ## Let's play with JSON to access **the NARA Catalog Morgenthau Diaries** Series: # ### - we use an API call where we specify a NARA Series ID directly: 589213 # ### - API Call: # # |
NARA Catalog Hierarchy
|
JSON Structure for the Query of FDR Series 589213: "The Morgenthau Diaries"
| # | ----- | ----- | # | | | # ### - Using Python to talk to NARA's Catalog through API calls: # In[33]: import requests import json # In[35]: #LISTING the 'Diaries of Henry Morgenthau, Jr.' Series, totalling over 850 volumes response = requests.get("https://catalog.archives.gov/api/v2/records/search?q=*&abbreviated=true&limit=200&title='Diaries'&naId=589213", headers={"Content-Type": "application/json", "x-api-key": "API-KEY"}) # If you take a look at the response, you’ll see that it is actually serialized JSON content # The following command will display the content in JSON format data = response.json() with open('data.HMJr.json', 'w') as f: json.dump(data, f) data # In[ ]: