Giter Club home page Giter Club logo

nasa's Introduction

nasa - Go library and apps based on the NASA API

CircleCI 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

nasa's People

Contributors

antoniomo avatar peteretelej avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.