'''
*Version: 2.0 Published: 2021/03/09* Source: [NASA POWER](https://power.larc.nasa.gov/)
POWER API Multi-Point Download
This is an overview of the process to request data from multiple data points from the POWER API.
'''
import os, json, requests
locations = [(11, 12), (5, 10)]
output = r""
base_url = r"https://power.larc.nasa.gov/api/temporal/hourly/point?parameters=T2M&community=SB&longitude=0&latitude=0&start=20170101&end=20170102&format=JSON"
for latitude, longitude in locations:
api_request_url = base_url.format(longitude=longitude, latitude=latitude)
response = requests.get(url=api_request_url, verify=True, timeout=30.00)
content = json.loads(response.content.decode('utf-8'))
filename = response.headers['content-disposition'].split('filename=')[1]
filepath = os.path.join(output, filename)
with open(filepath, 'w') as file_object:
json.dump(content, file_object)