This section provides code examples on how to access data from the RESTful Application Programming Interfaces (APIs). For more information on the API services, please see the API Services Section.
Guidance on Multiprocessing Download (Synchronous Requests)
When requesting data from the POWER API:
Please ensure you do not submit too many synchronous requests. If the server determines that you are negatively impacting performance, it may block your access.
Please ensure that you properly request data from the POWER data services at no higher than its current resolution. The POWER data products are currently available at a 0.5 x 0.625 degree resolution for meteorology and 1 x 1 for solar parameters. If you are requesting data at too high a resolution (i.e., less than 0.5 degree or about 50 km), you may be repeatedly requesting the same information.
Within two to three (2–3) months after real-time, improved climate quality data products replace the meteorological data products. You need to take this into account when downloading the POWER Data Archive.
The NASA Prediction of Worldwide Energy Resources (POWER) project provides free, globally available climate data for applications in energy, agriculture, and infrastructure. This tutorial will guide you through how to:
Understand and use the POWER application programming interface (API).
Retrieve real-world climate data.
Visualize data using Python.
Additional Resources
POWER API Documentation: https://power.larc.nasa.gov/docs/services/api/ Parameter Dictionary: https://power.larc.nasa.gov/parameters/
'''*Version: 1.0 Published: 2025/12/31* Source: [NASA POWER](https://power.larc.nasa.gov/)POWER API Single-Point Pandas AccessThis is an overview of the process to request and pandas dataframe for a point location from the POWER API.'''importpandasaspdurl="https://power.larc.nasa.gov/api/temporal/hourly/point?parameters=T2M,ALLSKY_SFC_SW_DWN&community=RE&longitude=-112.0740&latitude=33.4484&start=20241201&end=20241231&format=csv&header=false"df=pd.read_csv(url)time_mapping={"YEAR":"year","MO":"month","DY":"day","HR":"hour"}df=df.rename(columns=time_mapping)df["time"]=pd.to_datetime(df[time_mapping.values()])df=df.drop(columns=time_mapping.values())df=df.set_index("time")print(df)
1 2 3 4 5 6 7 8 91011121314
'''*Version: 1.0 Published: 2025/12/30* Source: [NASA POWER](https://power.larc.nasa.gov/)POWER API Single-Point Xarray AccessThis is an overview of the process to request and xarray dataframe for a point location from the POWER API.'''url="https://power.larc.nasa.gov/api/temporal/hourly/point?parameters=T2M,ALLSKY_SFC_SW_DWN&community=RE&longitude=-112.0740&latitude=33.4484&start=20241201&end=20241231&format=xarray"response=requests.get(url,verify=True,allow_redirects=True,timeout=30)response.raise_for_status()ds=xr.Dataset.from_dict(response.json())print(ds)
This is an overview of the process to request data from multiple single point locations from the POWER API.
The code under the Loop (Points) tab below allows you to download directly from the API in any available format.
The code under the Multiprocessing (Points) and Multiprocessing (Region) tabs supports multiprocessing and reads data from the JSON response, loading it into a Pandas DataFrame before exporting it as a CSV file. This can be modified to generate other formats using Python and/or the Pandas module.
1 2 3 4 5 6 7 8 9101112131415161718192021222324
'''*Version: 2.0 Published: 2021/03/09* Source: [NASA POWER](https://power.larc.nasa.gov/)POWER API Multi-Point DownloadThis is an overview of the process to request data from multiple data points from the POWER API.'''importos,json,requestslocations=[(32.929,-95.770),(5,10)]output=r""base_url=r"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M,T2MDEW,T2MWET,TS,T2M_RANGE,T2M_MAX,T2M_MIN&community=RE&longitude={longitude}&latitude={latitude}&start=20150101&end=20150305&format=JSON"forlatitude,longitudeinlocations: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)withopen(filepath,'w')asfile_object:json.dump(content,file_object)
'''*Version: 2.0 Published: 2021/03/09* Source: [NASA POWER](https://power.larc.nasa.gov/)POWER API Multi-Point DownloadThis is an overview of the process to request data from multiple data points from the POWER API.'''importos,sys,time,json,urllib3,requests,multiprocessingurllib3.disable_warnings()defdownload_function(collection):''' '''request,filepath=collectionresponse=requests.get(url=request,verify=False,timeout=30.00).json()withopen(filepath,'w')asfile_object:json.dump(response,file_object)classProcess():def__init__(self):self.processes=5# Please do not go more than five concurrent requests.self.request_template=r"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M,T2MDEW,T2MWET,TS,T2M_RANGE,T2M_MAX,T2M_MIN&community=RE&longitude={longitude}&latitude={latitude}&start=20150101&end=20150305&format=JSON"self.filename_template="File_Lat_{latitude}_Lon_{longitude}.csv"self.messages=[]self.times={}defexecute(self):Start_Time=time.time()locations=[(39.9373,-83.0485),(10.9373,-50.0485)]requests=[]forlatitude,longitudeinlocations:request=self.request_template.format(latitude=latitude,longitude=longitude)filename=self.filename_template.format(latitude=latitude,longitude=longitude)requests.append((request,filename))requests_total=len(requests)pool=multiprocessing.Pool(self.processes)x=pool.imap_unordered(download_function,requests)fori,dfinenumerate(x,1):sys.stderr.write('\rExporting {0:%}'.format(i/requests_total))self.times["Total Script"]=round((time.time()-Start_Time),2)print("\n")print("Total Script Time:",self.times["Total Script"])if__name__=='__main__':Process().execute()
'''*Version: 1.0 Published: 2020/02/11* Source: [NASA POWER](https://power.larc.nasa.gov/)POWER API Multipoint Download (CSV)This is an overview of the process to request data from multiple data points from the POWER API.'''importos,sys,time,json,urllib3,requests,multiprocessingurllib3.disable_warnings()importnumpyasnpdefdownload_function(collection):''' '''request,filepath=collectionresponse=requests.get(url=request,verify=False,timeout=30.00).json()withopen(filepath,'w')asfile_object:json.dump(response,file_object)classProcess():def__init__(self):self.processes=5# Please do not go more than five concurrent requests.self.request_template=r"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M,T2MDEW,T2MWET,TS,T2M_RANGE,T2M_MAX,T2M_MIN&community=RE&longitude={longitude}&latitude={latitude}&start=20150101&end=20150305&format=JSON"self.filename_template="File_Lat_{latitude}_Lon_{longitude}.csv"self.messages=[]self.times={}defexecute(self):Start_Time=time.time()latitudes=np.arange(-1.75,1.0,0.5)# Update your download extent.longitudes=np.arange(-1.75,1.0,0.5)# Update your download extent.requests=[]forlongitudeinlongitudes:forlatitudeinlatitudes:request=self.request_template.format(latitude=latitude,longitude=longitude)filename=self.filename_template.format(latitude=latitude,longitude=longitude)requests.append((request,filename))requests_total=len(requests)pool=multiprocessing.Pool(self.processes)x=pool.imap_unordered(download_function,requests)fori,dfinenumerate(x,1):sys.stderr.write('\rExporting {0:%}'.format(i/requests_total))self.times["Total Script"]=round((time.time()-Start_Time),2)print("\n")print("Total Script Time:",self.times["Total Script"])if__name__=='__main__':Process().execute()