#!/usr/bin/env python # coding: utf-8 # ## NARA API Catalog Queries for the WWII War Relocation Authority (WRA): # # For example, you can open a NARA catalog URL that runs an **API Catablog query** showing **all 106 Series** under the records of **RG 210 War Relocation Authority (WRA)**. The query returns JSON data which is displayed in the *jsoneditoronline.org* browser: # - "https://catalog.archives.gov/api/v2/records/parentNaId/537?parentNaid=537&abbreviated=true&limit=200" # where NARA ID 537 is the unique ID for RG210. # # |
NARA Catalog Hierarchy
|
JSON Structure for the Query of RG210's 106 Series
| # | ----- | ----- | # | | | # # --- # # Let's examine **the NARA Catalog JSON** next: # # In[68]: import requests import json response = requests.get("https://catalog.archives.gov/api/v2/records/parentNaId/537?parentNaid=537&abbreviated=true&limit=200", headers={"Content-Type": "application/json", "x-api-key": "API_KEY"}) data = response.json() #print( data ) with open('data.json', 'w') as f: json.dump(data, f) count = data["body"]["hits"]["total"]["value"] digObjs = 0 print( "Number of Series:", count ) print( "------------------------------------------------------------------------" ) for i in range(0, count): result = data["body"]["hits"]["hits"][i] fields = result["fields"] record = result["_source"]["record"] if record.get( "variantControlNumbers" ) is not None: print( "SERIES", i, " - ", record["variantControlNumbers"][0]["number"] ) else: print( "SERIES", i ) print( " - TITLE:\t\t", record["title"], ", ", record["inclusiveStartDate"]["year"], "-", record["inclusiveEndDate"]["year"] ) print( " - NARA ID:\t\t", record["creators"][0]["naId"] ) print( " - NUM Dig Objects:\t", fields["totalDigitalObjects"][0] ) digObjs = digObjs + fields["totalDigitalObjects"][0] if record.get( "scopeAndContentNote" ) is not None: print( "\nSCOPE & CONTENT NOTE:\n" ) print( record["scopeAndContentNote"] ) print( "\n------------------------------------------------------------------------" ) print( "\nTOTAL DIGITAL OBJECTS:", digObjs) # In[ ]: