Skip to content

peteretelej/nasa

Repository files navigation

nasa - Go library and apps based on the NASA API

CircleCI FOSSA Status

GoDoc Go Report Card

Includes:

  • Go Library for accessing and using the NASA API (APOD, NEO)
  • Command line interface (CLI) for accessing NASA API's services
  • Apps based on the NASA API: e.g. Desktop Wallpapers, Web Server for APOD and Random APOD ..

NASA API KEY

Kindly grab a NASA API key from here, and set it to the environment variable NASAKEY.

export NASAKEY=YOUR-API_KEY

The API Key will increase the rate limits for your application/package to access the NASA API. This package & its apps default to the demo key NASAKEY=DEMO_KEY if you haven't set one. The DEMO_KEY has very low limits (30reqs/hr, 50req/day), only sufficient for demoing.

nasa Library Usage

package main

import (
	"fmt"
	"log"
	"time"

	"github.com/peteretelej/nasa"
)

func main() {
	apod, err := nasa.ApodImage(time.Now())
	handle(err)
	fmt.Println(apod)

	// apod has structure of nasa.Image, hence get details with:
	// apod.Date, apod.Title, apod.Explanation, apod.URL, apod.HDURL etc
	fmt.Printf("Today's APOD is %s, available at %s", apod.Title, apod.HDURL)

	lastweek := time.Now().Add(-(7 * 24 * time.Hour))
	apod, err = nasa.ApodImage(lastweek)
	handle(err)
	fmt.Printf("APOD for 1 week ago:\n%s\n", apod)
}
func handle(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

nasa CLI

# installation
go get -u github.com/peteretelej/nasa/cmd/nasa

nasa apod 
# returns the NASA Astronomy Picture of the day

nasa apod -date 2016-01-17 
# returns the NASA APOD for the date specified

nasa neo
# returns Near Earth Objects for today

nasa neo -start 2017-05-10 -end 2017-05-12
# returns Near Earth Objects for the range of dates specified

Webserver for APOD pictures and Random Pics

Serve APOD on the web (demo: nasa.etelej.com)

nasa web
# serves website at :8080

nasa web -listen localhost:9000
# serves website at localhost:9000

Web server demo pages:

NASA Desktop Wallpapers

Automatically change your desktop wallpaper to randomly selected NASA Astronomy Pictures of the Day.

  • Supports various Linux desktop variants (at the moment) incl Gnome, Gnome2, Lubuntu, KDE and others.
  • Also supports custom command to set the wallpaper.
go get -u github.com/peteretelej/nasa/cmd/nasa-wallpapers

nasa-wallpapers
# automatically changes wallpapers every 10 minutes
# tries to change wallpaper with an existing command, use -cmdDefault to change the default command
# e.g -cmdDefault feh

nasa-wallpapers -cmdDefault gnome
# uses the gnome command for changing wallpapers (ie gsettings)

nasa-wallpapers -interval 30s -cmdDefault kde
# automatically changes wallpaper every 30seconds
# rem to get and set NASA API KEY to env NASAKEY to avoid ratelimits

nasa-wallpapers -cmd "myCustomCommand %s"
# automatically changes wallpaper every 10 minutes with myCustomCommand

License

FOSSA Status

About

Go Library for accessing the NASA API, nasa CLI and apps

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages