NASA doesn't just explore space — they give away their data for free. No credit card. No rate limit headaches. Just an API key you get in 10 seconds and access to Mars rover photos, asteroid tracking, the Astronomy Picture of the Day, and satellite imagery.
Here's how to use it.
Get Your Free API Key
Go to api.nasa.gov and enter your name and email. You'll get a key instantly. You can also use DEMO_KEY for testing (30 requests/hour).
1. Astronomy Picture of the Day (APOD)
Every day, NASA publishes a stunning space image with an explanation written by a professional astronomer.
curl "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY"
Response:
{
"date": "2026-03-27",
"title": "The Crab Nebula from Hubble",
"explanation": "This is a mosaic image...",
"url": "https://apod.nasa.gov/apod/image/2603/crab_hubble.jpg",
"hdurl": "https://apod.nasa.gov/apod/image/2603/crab_hubble_full.jpg",
"media_type": "image"
}
Get a date range:
curl "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&start_date=2026-03-01&end_date=2026-03-07"
2. Mars Rover Photos
Three rovers have sent back over 1 million photos. You can query by Earth date or Martian sol.
# Curiosity rover photos from a specific Earth date
curl "https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?earth_date=2026-03-01&api_key=DEMO_KEY"
Filter by camera:
# Front Hazard Avoidance Camera
curl "https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&camera=fhaz&api_key=DEMO_KEY"
Available cameras: FHAZ, RHAZ, MAST, CHEMCAM, MAHLI, MARDI, NAVCAM.
3. Near Earth Object (NEO) — Asteroid Tracker
Track asteroids passing close to Earth. This is real data used by planetary defense scientists.
# Asteroids approaching Earth this week
curl "https://api.nasa.gov/neo/rest/v1/feed?start_date=2026-03-27&end_date=2026-03-28&api_key=DEMO_KEY"
The response includes estimated diameter, velocity, miss distance, and whether the asteroid is potentially hazardous.
4. Earth Imagery (Landsat)
Get satellite photos of any location on Earth.
# Satellite image of the Eiffel Tower area
curl "https://api.nasa.gov/planetary/earth/imagery?lon=2.2945&lat=48.8584&date=2025-01-01&dim=0.1&api_key=DEMO_KEY"
5. Python Example — Build a Mars Photo Gallery
import requests
API_KEY = "YOUR_API_KEY" # Get free at api.nasa.gov
def get_mars_photos(earth_date="2026-03-01", rover="curiosity"):
url = f"https://api.nasa.gov/mars-photos/api/v1/rovers/{rover}/photos"
response = requests.get(url, params={
"earth_date": earth_date,
"api_key": API_KEY
})
photos = response.json().get("photos", [])
for photo in photos[:5]:
print(f"Camera: {photo['camera']['full_name']}")
print(f"Image: {photo['img_src']}")
print()
get_mars_photos()
6. Node.js Example — Daily Space Image Bot
const API_KEY = "YOUR_API_KEY";
async function getDailySpaceImage() {
const res = await fetch(
`https://api.nasa.gov/planetary/apod?api_key=${API_KEY}`
);
const data = await res.json();
console.log(`Today: ${data.title}`);
console.log(`Image: ${data.url}`);
console.log(`Explanation: ${data.explanation.slice(0, 200)}...`);
}
getDailySpaceImage();
Rate Limits
| Plan | Limit |
|---|---|
| DEMO_KEY | 30/hour, 50/day |
| Free API key | 1,000/hour |
For 99% of projects, the free key is more than enough.
What You Can Build
- Daily space wallpaper app — APOD endpoint + cron job
- Asteroid alert system — NEO feed + notification service
- Mars exploration viewer — Rover photos + date picker UI
- Earth observation dashboard — Landsat imagery + location search
- Space data aggregator — combine multiple NASA endpoints
More Free API Articles
- CoinGecko Has a Free API — Get Crypto Prices Without a Key
- Open-Meteo Has a Free Weather API — No Key, No Signup
- Discord Has a Free API — Build Bots and Automate Servers
Need Web Data? Try These Tools
If you're building apps that need web scraping or data extraction, check out my ready-made tools on Apify Store — scrapers for Reddit, YouTube, Google News, Trustpilot, and 80+ more. No coding needed, just run and get your data.
Need a custom scraping solution? Email me at spinov001@gmail.com
More Free APIs You Should Know About
- 30+ Free APIs Every Developer Should Bookmark
- Mapbox Has a Free API
- Claude AI Has a Free API
- SendGrid Has a Free API
- Vercel Has a Free API
- Firebase Has a Free API
- Supabase Has a Free API
- OpenAI Has a Free API
- Twilio Has a Free API
- Stripe Has a Free API
- GitHub API Has a Free API
Need custom data scraping? Email me or check my Apify actors.
Top comments (0)