DEV Community

Alex Spinov
Alex Spinov

Posted on

NASA Has 20+ Free APIs — Asteroids, Mars Photos, Exoplanets, and More (No Signup)

NASA gives you free access to their data. Mars rover photos. Near-Earth asteroids. Exoplanet databases. Solar flare alerts. And it all works with a single demo API key.

Getting Started

Use DEMO_KEY for testing (30 requests/hour) or get a free key at api.nasa.gov (1000/hour).

1. Astronomy Picture of the Day

import requests

resp = requests.get("https://api.nasa.gov/planetary/apod", params={
    "api_key": "DEMO_KEY"
})
data = resp.json()
print(f"Title: {data['title']}")
print(f"Date: {data['date']}")
print(f"URL: {data['url']}")
print(f"Explanation: {data['explanation'][:200]}...")
Enter fullscreen mode Exit fullscreen mode

2. Mars Rover Photos

# Get photos from Curiosity rover
resp = requests.get("https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos", params={
    "sol": 1000,  # Martian day
    "camera": "FHAZ",  # Front Hazard Avoidance Camera
    "api_key": "DEMO_KEY"
})

photos = resp.json()["photos"]
print(f"Found {len(photos)} photos from sol 1000")
for photo in photos[:3]:
    print(f"  Camera: {photo['camera']['full_name']}")
    print(f"  URL: {photo['img_src']}")
Enter fullscreen mode Exit fullscreen mode

3. Near-Earth Asteroids

# Asteroids approaching Earth this week
resp = requests.get("https://api.nasa.gov/neo/rest/v1/feed", params={
    "start_date": "2026-03-25",
    "end_date": "2026-03-27",
    "api_key": "DEMO_KEY"
})

data = resp.json()
print(f"Total asteroids this week: {data['element_count']}")

for date, asteroids in data["near_earth_objects"].items():
    for a in asteroids[:2]:
        name = a["name"]
        size = a["estimated_diameter"]["meters"]["estimated_diameter_max"]
        hazardous = a["is_potentially_hazardous_asteroid"]
        print(f"  {name}: {size:.0f}m diameter, hazardous={hazardous}")
Enter fullscreen mode Exit fullscreen mode

4. NASA Image Library

# Search NASA images (no key needed!)
resp = requests.get("https://images-api.nasa.gov/search", params={
    "q": "black hole",
    "media_type": "image"
})

items = resp.json()["collection"]["items"]
print(f"Found {len(items)} images")
for item in items[:3]:
    data = item["data"][0]
    print(f"  {data['title']} ({data.get('date_created', 'N/A')[:4]})")
    print(f"  {item['links'][0]['href']}")
Enter fullscreen mode Exit fullscreen mode

5. Exoplanet Archive

# Get confirmed exoplanets
resp = requests.get("https://exoplanetarchive.ipac.caltech.edu/TAP/sync", params={
    "query": "select pl_name,hostname,disc_year,pl_bmasse from pscomppars where disc_year>=2024 order by disc_year desc",
    "format": "json"
})

planets = resp.json()
print(f"Recent exoplanets: {len(planets)}")
for p in planets[:5]:
    mass = p.get("pl_bmasse", "?")
    print(f"  {p['pl_name']} (star: {p['hostname']}, {p['disc_year']}, {mass} Earth masses)")
Enter fullscreen mode Exit fullscreen mode

All NASA APIs

API What Key
APOD Daily astronomy image DEMO_KEY
Mars Rover Photos Mars surface images DEMO_KEY
NEO/Asteroids Near-Earth objects DEMO_KEY
NASA Images Photo/video library None
Exoplanet Archive 5000+ confirmed planets None
DONKI Space weather events DEMO_KEY
Earth Satellite imagery DEMO_KEY
EPIC Earth from deep space DEMO_KEY
GeneLab Space biology data None
TechTransfer NASA patents DEMO_KEY

Pro Tips

  1. DEMO_KEY works for testing (30 req/hr per IP)
  2. Free key at api.nasa.gov gives 1000 req/hr
  3. NASA Images API needs NO key at all
  4. Exoplanet Archive uses TAP/SQL-like queries
  5. DONKI API tracks solar flares, CMEs, geomagnetic storms

NASA data + Python = incredible projects. What would you build?

More free APIs: OpenAlex | World Bank | Full list

More tools: GitHub\n\n---\n\n## More Free Research APIs\n\nThis is part of my series on free APIs for researchers and data scientists:\n\n- OpenAlex API — 250M+ Academic Works\n- CORE API — 260M+ Scientific Papers\n- Crossref API — DOI Metadata for 150M+ Papers\n- Unpaywall API — Find Free Paper Versions\n- Europe PMC — 40M+ Biomedical Papers\n- World Bank API — GDP & Economic Data\n- ORCID API — 18M+ Researcher Profiles\n- DBLP API — 6M+ CS Publications\n- NASA APIs — 20+ Free Space Data APIs\n- FRED API — 800K+ US Economic Time Series\n- All 30+ Research APIs Mapped\n\n*Tools: Academic Research Toolkit on GitHub*

Top comments (0)