In [1]:
import csv
import json
import requests

In [2]:
base_ur = 'https://api.chorusaccess.org/agencies/100000001/histories'

In [3]:
funder_list = []

with open('funder_list.csv', mode='r') as funder_file:
    reader = csv.reader(funder_file)
    for row in reader:
        funder_dict = {}
        funder_dict['name'] = row[0]
        funder_dict['id'] = row[1]
        funder_list.append(funder_dict)
funder_list.pop(0)


Out[3]:
{'id': 'Funder ID', 'name': 'Funder Name'}

In [5]:
funder_list


Out[5]:
[{'id': '100000133', 'name': 'Agency for Healthcare Research and Quality'},
 {'id': '100000879', 'name': 'Alfred P. Sloan Foundation'},
 {'id': '100000865', 'name': 'Bill and Melinda Gates Foundation'},
 {'id': '100000030',
  'name': 'Centers for Disease Control and Prevention (CDC)'},
 {'id': '100000139', 'name': 'Environmental Protection Agency (EPA)'},
 {'id': '100000104',
  'name': 'National Aeronautics and Space Administration (NASA)'},
 {'id': '100000002', 'name': 'National Institutes of Health (NIH)'},
 {'id': '100000161',
  'name': 'National Institute of Standards and Technology (NIST)'},
 {'id': '100000192',
  'name': 'National Oceanic and Atmospheric Administration (NOAA)'},
 {'id': '100000001', 'name': 'National Science Foundation (NSF)'},
 {'id': '100005195',
  'name': 'Office of Public Health Preparedness and Response'},
 {'id': '100000014', 'name': 'Smithsonian Institution'},
 {'id': '100000200',
  'name': 'U.S. Agency for International Development (USAID)'},
 {'id': '100000199', 'name': 'U.S. Department of Agriculture (USDA)'},
 {'id': '100000005', 'name': 'U.S. Department of Defense (USDOD)'},
 {'id': '100000138', 'name': 'U.S. Department of Education'},
 {'id': '100000015', 'name': 'U.S. Department of Energy (USDOE)'},
 {'id': '100000016',
  'name': 'U.S. Department of Health and Human Services (USHHS)'},
 {'id': '100000180', 'name': 'U.S. Department of Homeland Security'},
 {'id': '100000201', 'name': 'U.S. Department of Interior (USDOI)'},
 {'id': '100000140', 'name': 'U.S. Department of Transportation (USDOT)'},
 {'id': '100000738', 'name': 'U.S. Department of Veterans Affairs'},
 {'id': '100000038', 'name': 'U.S. Food and Drug Administration (FDA)'},
 {'id': '100000203', 'name': 'U.S. Geological Survey (USGS)'},
 {'id': '100004421', 'name': 'World Bank Group'}]

In [4]:
test_url = 'https://api.chorusaccess.org/agencies/100000161/histories/2015/9/07?limit=500'

In [60]:
this_data = requests.get(test_url).json()['items']

In [61]:
len(this_data)


Out[61]:
367

In [55]:
one_thing = this_data[-1]

In [56]:
print(json.dumps(one_thing, indent=4))


{
    "publisher": "Optical Society of America (OSA)", 
    "DOI": "10.1364/optica.2.000141", 
    "title": "Attosecond timing in optical-to-electrical conversion", 
    "URL": "http://dx.doi.org/10.1364/optica.2.000141", 
    "audited_on": "3/9/2015", 
    "journal_name": "Optica", 
    "publicly_accessible_date": null, 
    "authors": [
        "Baynes Fred N.", 
        "Quinlan Franklyn", 
        "Fortier Tara M.", 
        "Zhou Qiugui", 
        "Beling Andreas", 
        "Campbell Joe C.", 
        "Diddams Scott A."
    ], 
    "publication_date": "2015"
}

In [57]:
another_url = 'https://api.chorusaccess.org/agencies/100000161/histories/2015/2/23?limit=500'

In [63]:
other_data = requests.get(another_url).json()['items']

In [64]:
len(other_data)


Out[64]:
141

In [59]:
print(json.dumps(other_data[-1], indent=4))


{
    "publisher": "Optical Society of America (OSA)", 
    "DOI": "10.1364/optica.2.000141", 
    "title": "Attosecond timing in optical-to-electrical conversion", 
    "URL": "http://dx.doi.org/10.1364/optica.2.000141", 
    "audited_on": "3/9/2015", 
    "journal_name": "Optica", 
    "publicly_accessible_date": null, 
    "authors": [
        "Baynes Fred N.", 
        "Quinlan Franklyn", 
        "Fortier Tara M.", 
        "Zhou Qiugui", 
        "Beling Andreas", 
        "Campbell Joe C.", 
        "Diddams Scott A."
    ], 
    "publication_date": "2015"
}

In [ ]: