Skip to content

Images - NASA Image, Video, and Audio Library

Images - NASA Image, Video, and Audio Library

Section titled “Images - NASA Image, Video, and Audio Library”

The ImageService provides access to NASA’s Image, Video, and Audio Library. No API key is required.

MethodSignatureDescription
SearchSearch(ctx context.Context, query string, opts ...ImageSearchOption) (*ImageCollection, error)Search images, videos, and audio
AssetAsset(ctx context.Context, nasaID string) (*AssetManifest, error)Get asset manifest for a NASA ID
MetadataMetadata(ctx context.Context, nasaID string) (map[string]any, error)Get metadata for a NASA ID
CaptionsCaptions(ctx context.Context, nasaID string) (string, error)Get captions for a video
nasa.ImageWithMediaType("image") // filter by type: image, video, audio
nasa.ImageWithYearStart(2020) // results from this year or later
nasa.ImageWithYearEnd(2024) // results up to this year
nasa.ImageWithCenter("JPL") // filter by NASA center
nasa.ImageWithKeywords("mars") // filter by keywords
nasa.ImageWithPage(2) // results page number
nasa.ImageWithPageSize(50) // results per page
type ImageCollection struct {
Items []*ImageItem
TotalHits int
NextPage string
PrevPage string
}
type ImageItem struct {
NasaID string
Title string
Description string
MediaType string
Center string
DateCreated time.Time
Keywords []string
Photographer string
Location string
PreviewURL string
AssetURL string
}
type AssetManifest struct {
Items []AssetItem
}
type AssetItem struct {
Href string
}
package main
import (
"context"
"fmt"
"log"
"github.com/peteretelej/nasa"
)
func main() {
client := nasa.NewClient()
results, err := client.Images.Search(
context.Background(),
"apollo 11",
nasa.ImageWithMediaType("image"),
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total hits: %d\n\n", results.TotalHits)
for _, item := range results.Items {
fmt.Printf("%s (ID: %s)\n", item.Title, item.NasaID)
if item.PreviewURL != "" {
fmt.Printf(" Preview: %s\n", item.PreviewURL)
}
}
}
package main
import (
"context"
"fmt"
"log"
"github.com/peteretelej/nasa"
)
func main() {
client := nasa.NewClient()
manifest, err := client.Images.Asset(context.Background(), "as11-40-5874")
if err != nil {
log.Fatal(err)
}
for _, asset := range manifest.Items {
fmt.Println(asset.Href)
}
}