Nasa
Model Context Protocol server for NASA public APIs - Access space data, Mars rovers, asteroids, and more
Ask AI about Nasa
Powered by Claude · Grounded in docs
I know everything about Nasa. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
nasa
A Go client library for NASA's open APIs, covering APOD, NeoWs, DONKI, the Image Library, SSD/CNEOS, and EONET.
Query NASA's public data APIs from Go - astronomy photos, near-Earth objects, space weather events, satellite imagery, and more. Responses are returned as typed Go structs with rate limiting handled automatically. A CLI and an MCP server are also included for terminal and AI assistant usage.
- 6 NASA APIs - APOD, NeoWs, DONKI, NASA Image Library, SSD/CNEOS, EONET
- Built-in rate limiting - automatic 429 retry with header-based dynamic adjustment
- Typed responses - strongly typed Go structs, no raw JSON
- Context-aware - supports cancellation and timeouts
- CLI - access all APIs from the terminal
- MCP server - expose NASA APIs as tools for AI assistants
Install
go get github.com/peteretelej/nasa
API Key
Get a free API key at api.nasa.gov, then export it:
export NASA_API_KEY=your_key_here
Or specify it directly when creating the client:
client := nasa.NewClient(nasa.WithAPIKey("your_key_here"))
The SDK works without a key using NASA's DEMO_KEY, but it is heavily rate-limited.
Quick Start
package main
import (
"context"
"fmt"
"log"
"github.com/peteretelej/nasa"
)
func main() {
client := nasa.NewClient()
apod, err := client.APOD.Today(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s: %s\n", apod.Title, apod.URL)
}
API Coverage
| API | Description | Service |
|---|---|---|
| APOD | Astronomy Picture of the Day | client.APOD |
| NeoWs | Near-Earth Object Web Service | client.NEO |
| DONKI | Space Weather Database and Notification System | client.DONKI |
| NASA Image Library | Image and video search across NASA media | client.Images |
| SSD/CNEOS | Close approaches, fireballs, small bodies | client.SSD |
| EONET | Earth Observatory Natural Event Tracker | client.EONET |
Rate Limiting
The client automatically respects NASA API rate limits. With a registered key, the default is 1000 requests/hour.
client := nasa.NewClient()
CLI
go install github.com/peteretelej/nasa/cmd/nasa@latest
nasa apod # today's Astronomy Picture of the Day
nasa apod -date 2024-01-01 # APOD for a specific date
nasa neo feed # near-Earth objects for today
nasa donki cme # coronal mass ejections
nasa images search "apollo 11" # search NASA image library
nasa ssd cad # close approach data
MCP Server
go install github.com/peteretelej/nasa/cmd/nasa-mcp@latest
Add to your MCP client config:
{
"mcpServers": {
"nasa": {
"command": "nasa-mcp",
"env": { "NASA_API_KEY": "your-key" }
}
}
}
The MCP server exposes 13 tools covering all 6 APIs. See the documentation for details.
Documentation
Full documentation at peteretelej.github.io/nasa.
Examples
Runnable programs covering every API are in examples/. Each is a single main.go with no external dependencies beyond the SDK.
Daily Briefing
Combines all six APIs into one summary - APOD, near-Earth objects, space weather, and active Earth events.
go run ./examples/daily-briefing
=== Today's APOD ===
Title: Hello World
URL: https://apod.nasa.gov/apod/image/2604/art002e000192_1050.jpg
=== Near-Earth Objects This Week ===
105 objects tracked, 1 potentially hazardous
=== Solar Activity (7 days) ===
Coronal mass ejections: 43
Solar flares: 13
=== Active Earth Events ===
[Wildfires] rx-12_ 13_ 14 Prescribed Fire, Burnett, Wisconsin
[Wildfires] Rx Houston 3041 Prescribed Fire, Houston, Texas
[Severe Storms] Tropical Cyclone Indusa
[Wildfires] RX PCS Beauchamp North Prescribed Fire, Scott, Arkansas
[Wildfires] Julie Pond Wildfire, Dorchester, Maryland
APOD Gallery
Fetches today's Astronomy Picture of the Day plus a recent gallery.
go run ./examples/apod-gallery
NEO Watch
Tracks near-Earth objects for the current week, with details on close approaches and potentially hazardous asteroids.
go run ./examples/neo-watch
Space Weather
Queries DONKI for recent coronal mass ejections, solar flares, geomagnetic storms, and other space weather events.
go run ./examples/space-weather
Image Search
Searches the NASA Image and Video Library for media, with metadata and download links.
go run ./examples/image-search
Close Approaches
Queries SSD/CNEOS for recent fireballs, upcoming close approaches, and small body lookups.
go run ./examples/close-approaches
Earth Events
Lists active natural events from EONET - wildfires, storms, volcanic activity, and more.
go run ./examples/earth-events
Contributing
See CONTRIBUTING.md.
