Skip to content

DONKI - Space Weather Database

The DONKIService provides access to NASA’s Space Weather Database of Notifications, Knowledge, Information (DONKI). Requires an API key (uses DEMO_KEY by default).

All methods accept a date range (start, end as time.Time):

MethodReturnsDescription
CME[]*CMEEventCoronal Mass Ejections
CMEAnalysis[]*CMEAnalysisCME analysis data (with optional filters)
GST[]*GSTEventGeomagnetic Storms
IPS[]*IPSEventInterplanetary Shocks (with optional filters)
FLR[]*FLREventSolar Flares
SEP[]*SEPEventSolar Energetic Particles
MPC[]*MPCEventMagnetopause Crossings
RBE[]*RBEEventRadiation Belt Enhancements
HSS[]*HSSEventHigh Speed Streams
WSAEnlil[]*WSAEnlilEventWSA-Enlil Simulations
Notifications[]*NotificationDONKI notifications (with type filter)
func (s *DONKIService) CME(ctx context.Context, start, end time.Time) ([]*CMEEvent, error)
func (s *DONKIService) CMEAnalysis(ctx context.Context, start, end time.Time, opts ...CMEAnalysisOption) ([]*CMEAnalysis, error)
func (s *DONKIService) GST(ctx context.Context, start, end time.Time) ([]*GSTEvent, error)
func (s *DONKIService) IPS(ctx context.Context, start, end time.Time, opts ...IPSOption) ([]*IPSEvent, error)
func (s *DONKIService) FLR(ctx context.Context, start, end time.Time) ([]*FLREvent, error)
func (s *DONKIService) SEP(ctx context.Context, start, end time.Time) ([]*SEPEvent, error)
func (s *DONKIService) MPC(ctx context.Context, start, end time.Time) ([]*MPCEvent, error)
func (s *DONKIService) RBE(ctx context.Context, start, end time.Time) ([]*RBEEvent, error)
func (s *DONKIService) HSS(ctx context.Context, start, end time.Time) ([]*HSSEvent, error)
func (s *DONKIService) WSAEnlil(ctx context.Context, start, end time.Time) ([]*WSAEnlilEvent, error)
func (s *DONKIService) Notifications(ctx context.Context, start, end time.Time, notificationType string) ([]*Notification, error)
nasa.WithMostAccurateOnly(true) // filter to most accurate entries
nasa.WithCompleteEntryOnly(true) // filter to complete entries
nasa.WithSpeed(min) // minimum speed (km/s)
nasa.WithHalfAngle(min) // minimum half-angle (degrees)
nasa.WithCatalog("M2M_CATALOG") // filter by catalog
nasa.WithLocation("Earth") // location filter
nasa.WithIPSCatalog("WINSLOW_MESSENGER_ICME_CATALOG") // catalog filter

All DONKI timestamps use DONKITime, which embeds time.Time and handles NASA’s date format automatically.

type CMEEvent struct {
ActivityID string
Catalog string
StartTime DONKITime
SourceLocation string
ActiveRegionNum int
Link string
Note string
Instruments []CMEInstrument
CMEAnalyses []CMEAnalysisData
LinkedEvents []LinkedEvent
}
package main
import (
"context"
"fmt"
"log"
"os"
"time"
"github.com/peteretelej/nasa"
)
func main() {
client := nasa.NewClient(
nasa.WithAPIKey(os.Getenv("NASA_API_KEY")),
)
end := time.Now()
start := end.AddDate(0, 0, -30)
events, err := client.DONKI.CME(context.Background(), start, end)
if err != nil {
log.Fatal(err)
}
fmt.Printf("CME events in last 30 days: %d\n\n", len(events))
for _, e := range events {
fmt.Printf("ID: %s\n", e.ActivityID)
fmt.Printf("Start: %s\n", e.StartTime.Format(time.RFC3339))
fmt.Printf("Source: %s\n\n", e.SourceLocation)
}
}
package main
import (
"context"
"fmt"
"log"
"os"
"time"
"github.com/peteretelej/nasa"
)
func main() {
client := nasa.NewClient(
nasa.WithAPIKey(os.Getenv("NASA_API_KEY")),
)
end := time.Now()
start := end.AddDate(0, 0, -30)
analyses, err := client.DONKI.CMEAnalysis(
context.Background(), start, end,
nasa.WithMostAccurateOnly(true),
nasa.WithSpeed(500),
)
if err != nil {
log.Fatal(err)
}
for _, a := range analyses {
fmt.Printf("Speed: %.0f km/s, Half-angle: %.0f deg\n", a.Speed, a.HalfAngle)
}
}