Nasapy Documentation

nasapy is a Python wrapper for the API.


nasapy is most easily installed using pip.

pip install nasapy

The library can also be cloned or downloaded into a location of your choosing and then installed using the file per the following:

git clone
cd nasapy
python install


  • Python 3.4+
  • requests>=2.18
  • pandas>=0.22.0
  • Although not strictly required to use nasapy, the pandas library is needed for returning results as a DataFrame.

Examples and Usage

Although not strictly required to begin interacting with the NASA API, it is recommended to sign up to receive an API access key that has a significantly higher usage limit available compared to the demo key option. Many methods do not require an API key, but for those that do, it is typically a good option to use a provided API key rather than the demo key. Using a received API key allows for 1,000 requests per hour, while the demo key has 30 requests limit per hour and 50 requests per day.


Assuming an API key was received after signing up, authentication to the NASA API happens when initializing the Nasa class.

nasa = Nasa(key=key)

If using a demo key, the initialization does not require any parameters to be passed.

nasa = Nasa()

Remaining Requests Available

The limit_remaining attribute of the initialized Nasa class allows one to see the number of available requests remaining.



The following are some quick examples to get started.

Astronomy Picture of the Day

# Return today's picture of the day
# Return a previous date's picture of the day with the high-definition URL included.
nasa.picture_of_the_day('2019-01-01', hd=True)

Mars Weather

# Return the most recent data for the previous seven Sols (Martian Days)

Asteroid Feed

# Get asteroids approaching Earth at the beginning of 2019.

Get Asteroid Data

# Get entire asteroid data set.
# Get asteroid with ID 3542519

DONKI (Space Weather Database of Notifications, Knowledge and Information)

# Coronal Mass Ejection Event Data

# View data from coronal mass ejection events from the last thirty days
# View all CME events from the beginning of 2019.

# Geomagnetic Storm Event Data

# Get geomagnetic storm events from the last thirty days.

# Solar Flare Event Data

# Get solar flare events from May of 2019
nasa.solar_flare(start_date='2019-05-01', end_date='2019-05-31')

# Solar Energetic Particle Data

# Get data from April 2017
nasa.solar_energetic_particle(start_date='2017-04-01', end_date='2017-04-30')

# Magnetopause Crossing Data

# Get data on magnetopause crossing events from 2018 to the current date.

# Radiation Belt Enhancement Data

# Get data on radiation belt enhancement events from the last 30 days.

# Hight Speed Stream Data

# Get data on hight speed stream events from the beginning of September 2019.

# WSA Enlil-Simulation Data

# Get data from the first simulation performed in 2019.
wsa = n.wsa_enlil_simulation(start_date='2019-01-01')

EPIC (DSCOVR’s Earth Polychromatic Imaging Camera)

# Get EPIC data from the beginning of 2019.
e = nasa.epic(date='2019-01-01')
# Print the first result


# Get all exoplanets data as a pandas DataFrame.
# Get all confirmed planets in the Kepler field.
# Stars known to host exoplanets as a pandas DataFrame.
exoplanets(select='distinct pl_hostname', order='pl_hostname', return_df=True)

Landsat Images for a given Latitude-Longitude

# Get imagery at latitude 1.5, longitude 100.75 and include the computed cloud score calculation.
nasa.earth_imagery(lon=100.75, lat=1.5, cloud_score=True)

# Get assets available beginning from 2014-02-01 at lat-lon 100.75, 1.5
nasa.earth_assets(lat=100.75, lon=1.5, begin_date='2014-02-01')

Available Image data collected by the Mars rovers Curiosity, Discovery and Spirit.

# Return image data collected on Curiosity's 1000th sol.

Access GeneLab and Other Bioinformatics Databases

# Find Gene studies in the cgene database related to 'mouse liver'
n.genelab_search(term='mouse liver')

CelesTrak Two-Line Element Set Records

# Retrieve available data for a specific satellite ID.

Search for Available Imagery and Audio from the API

# Search for media related to 'apollo 11' with 'moon landing' in the description of the items.
r = media_search(query='apollo 11', description='moon landing')
# Print the first returned media item from the resulting collection.

Getting the Julian and Modified Julian Date

# Return the modified Julian Date for the current time.
# Return the non-modified Julian Date for the current time.
# Get the modified Julian Date for 2019-01-01 at midnight.