Skip to content

API Data Requests

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.

Single-Point

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/

Guide to Download Data

1) Choose Your Parameters: For this tutorial, we’ll focus on solar radiation (ALLSKY_SFC_SW_DWN), which is essential for solar energy applications.

2) Define Your Location and Time Range: Phoenix, Arizona (Latitude: 33.4484, Longitude: -112.0740) and Time Range: January 1, 2020 – December 31, 2020

3) Construct the API URL:

1
    /api/temporal/daily/point?parameters=ALLSKY_SFC_SW_DWN&community=RE&longitude=-112.0740&latitude=33.4484&start=20200101&end=20201231&format=JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
'''
*Version: 1.0 Published: 2025/12/31* Source: [NASA POWER](https://power.larc.nasa.gov/)
POWER API Single-Point Pandas Access
This is an overview of the process to request and pandas dataframe for a point location from the POWER API.
'''

import pandas as pd

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=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
 9
10
11
12
13
14
'''
*Version: 1.0 Published: 2025/12/30* Source: [NASA POWER](https://power.larc.nasa.gov/)
POWER API Single-Point Xarray Access
This 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)

Multi-Point

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
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'''
*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 = [(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"

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)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'''
*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, sys, time, json, urllib3, requests, multiprocessing

urllib3.disable_warnings()

def download_function(collection):
    ''' '''

    request, filepath = collection
    response = requests.get(url=request, verify=False, timeout=30.00).json()

    with open(filepath, 'w') as file_object:
        json.dump(response, file_object)

class Process():

    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 = {}

    def execute(self):

        Start_Time = time.time()

        locations = [(39.9373, -83.0485), (10.9373, -50.0485)]

        requests = []
        for latitude, longitude in locations:
            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)

        for i, df in enumerate(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()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'''
*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.
'''

import os, sys, time, json, urllib3, requests, multiprocessing

urllib3.disable_warnings()

import numpy as np

def download_function(collection):
    ''' '''

    request, filepath = collection
    response = requests.get(url=request, verify=False, timeout=30.00).json()

    with open(filepath, 'w') as file_object:
        json.dump(response, file_object)

class Process():

    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 = {}

    def execute(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 = []
        for longitude in longitudes:
            for latitude in latitudes:
                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)

        for i, df in enumerate(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()