Data source: NASA Open APIs (api.nasa.gov)
Overview
NASA wraps NASA Open APIs (api.nasa.gov), handling authentication, pagination, and rate limits for you. This tutorial covers all 6 tools with working code examples you can copy and run.
Prerequisites
- Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
- Choose your integration method: MCP protocol or REST API.
Connect via MCP
Add to your MCP client config (Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"gnist-nasa": {
"url": "https://context.gnist.ai/mcp/nasa/",
"headers": {
"Gnist-API-Key": "YOUR_API_KEY"
}
}
}
}
Tools (6)
search_apod
Get NASA's Astronomy Picture of the Day with scientific explanations. Returns high-quality astronomy images or videos with detailed explanations from professional astronomers. Data goes back to June 1995. Examples: search_apod() -> today's picture search_apod(date="2024-01-01") -> specific date search_apod(start_date="2024-01-01", end_date="2024-01-07") -> date range search_apod(count=5) -> 5 random pictures
| Parameter | Type | Required | Description |
|---|---|---|---|
date | any | optional | Specific date (YYYY-MM-DD). Omit for today's picture. |
start_date | any | optional | Start date for a date range (YYYY-MM-DD). |
end_date | any | optional | End date for a date range (YYYY-MM-DD). |
count | any | optional | Return N random APOD entries (1-100). Cannot combine with date/start_date. |
curl -X POST "https://context.gnist.ai/mcp/nasa/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_apod", "arguments": {"date": "2025-01-15"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/nasa/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'date': '2025-01-15'}, 'name': 'search_apod'}},
)
print(resp.json())
search_neo
Search Near Earth Objects (asteroids and comets) by date range. Returns orbital data, size estimates, close approach distances, velocities, and whether each object is classified as potentially hazardous. Maximum 7-day range per query. Use for asteroid tracking, impact risk assessment, and space situational awareness. Examples: search_neo("2024-01-01", "2024-01-07") -> week of NEO data
| Parameter | Type | Required | Description |
|---|---|---|---|
start_date | string | required | Start date (YYYY-MM-DD). |
end_date | string | required | End date (YYYY-MM-DD), max 7 days from start. |
curl -X POST "https://context.gnist.ai/mcp/nasa/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_neo", "arguments": {"start_date": "2025-01-15", "end_date": "2025-01-15"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/nasa/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'end_date': '2025-01-15', 'start_date': '2025-01-15'},
'name': 'search_neo'}},
)
print(resp.json())
search_mars_photos
Search Mars Rover photos from Curiosity, Opportunity, Spirit, and Perseverance. Each rover has different cameras. Common cameras: - FHAZ/RHAZ: Front/Rear Hazard Avoidance (all rovers) - NAVCAM: Navigation Camera (all rovers) - MAST: Mast Camera (Curiosity) - PANCAM: Panoramic Camera (Opportunity, Spirit) Examples: search_mars_photos("curiosity", sol=1000) -> Curiosity photos from sol 1000 search_mars_photos("perseverance", earth_date="2024-01-15", camera="NAVCAM")
| Parameter | Type | Required | Description |
|---|---|---|---|
rover | string | required | Rover name: curiosity, opportunity, spirit, or perseverance. |
sol | any | optional | Martian sol (day) number. Default 1000 if neither sol nor earth_date given. |
earth_date | any | optional | Earth date (YYYY-MM-DD). Alternative to sol. |
camera | any | optional | Camera abbreviation: FHAZ, RHAZ, MAST, CHEMCAM, MAHLI, NAVCAM, PANCAM, etc. |
page | integer | optional | Page number (25 results per page). Default 1. (default: 1) |
curl -X POST "https://context.gnist.ai/mcp/nasa/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_mars_photos", "arguments": {"rover": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/nasa/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'rover': 'example'}, 'name': 'search_mars_photos'}},
)
print(resp.json())
get_epic_imagery
Get NASA EPIC full-disc Earth photographs from DSCOVR satellite at L1 point. Returns metadata and image URLs for full-color photographs of the sunlit side of Earth, taken from 1 million miles away. Available in natural color and contrast-enhanced versions. Examples: get_epic_imagery() -> most recent natural color images get_epic_imagery(collection="enhanced") -> enhanced images get_epic_imagery(date="2024-01-15") -> specific date
| Parameter | Type | Required | Description |
|---|---|---|---|
collection | string | optional | Image collection: 'natural' (color) or 'enhanced' (contrast-enhanced). (default: natural) |
date | any | optional | Date (YYYY-MM-DD). Omit for most recent images. |
curl -X POST "https://context.gnist.ai/mcp/nasa/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_epic_imagery", "arguments": {"collection": "natural"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/nasa/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'collection': 'natural'}, 'name': 'get_epic_imagery'}},
)
print(resp.json())
search_space_weather
Search NASA DONKI space weather events. The Space Weather Database Of Notifications, Knowledge, Information (DONKI) tracks solar and geomagnetic events that affect Earth. Event types: - CME: Coronal Mass Ejections — solar plasma eruptions - GST: Geomagnetic Storms — disturbances in Earth's magnetosphere - FLR: Solar Flares — electromagnetic radiation bursts - IPS: Interplanetary Shocks — shock waves in solar wind - SEP: Solar Energetic Particles — high-energy particle events - MPC: Magnetopause Crossings - RBE: Radiation Belt Enhancements - HSS: High Speed Streams — fast solar wind streams Examples: search_space_weather("CME", "2024-01-01", "2024-01-31") search_space_weather("FLR", "2024-03-01", "2024-03-15")
| Parameter | Type | Required | Description |
|---|---|---|---|
event_type | string | required | Event type: CME (Coronal Mass Ejection), GST (Geomagnetic Storm), FLR (Solar Flare), IPS (Interplanetary Shock), SEP (Solar Energetic Particle), MPC (Magnetopause Crossing), RBE (Radiation Belt Enhanc |
start_date | string | required | Start date (YYYY-MM-DD). |
end_date | string | required | End date (YYYY-MM-DD). |
curl -X POST "https://context.gnist.ai/mcp/nasa/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_space_weather", "arguments": {"event_type": "example", "start_date": "2025-01-15", "end_date": "2025-01-15"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/nasa/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'end_date': '2025-01-15',
'event_type': 'example',
'start_date': '2025-01-15'},
'name': 'search_space_weather'}},
)
print(resp.json())
report_feedback
Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.
| Parameter | Type | Required | Description |
|---|---|---|---|
feedback | string | required | |
feedback_type | string | optional | (default: general) |
curl -X POST "https://context.gnist.ai/mcp/nasa/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/nasa/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())
Common Patterns
Use
search_apod to find items, then get_epic_imagery to get full details. This two-step pattern is common for exploring data before drilling down.Several tools support
limit, offset, or page parameters. Start with small limits during development, then increase for production queries.Use date range parameters to narrow results to a specific time window. Dates are typically in
YYYY-MM-DD format.FAQ
What data does NASA provide?
NASA open APIs — Astronomy Picture of the Day, Near Earth Objects, Mars Rover Photos, EPIC Earth imagery, and DONKI space weather events. It exposes 6 tools: search_apod, search_neo, search_mars_photos, get_epic_imagery, search_space_weather, report_feedback.
What do I need to get started?
A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.
What format does the NASA API return?
JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.