Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/helixspiral/apod

Golang wrapper for the Astronomy Picture of the Day API from NASA
https://github.com/helixspiral/apod

api apod apod-api astronomy astronomy-picture astronomy-picture-of-the-day easy-to-use go golang nasa nasa-api nasa-apod nasa-apod-api nasa-astronomy-picture nasa-astronomy-picture-of-the-day nasa-data space space-api wrapper wrapper-api

Last synced: about 1 month ago
JSON representation

Golang wrapper for the Astronomy Picture of the Day API from NASA

Awesome Lists containing this project

README

        

Astronomy Picture of the Day API Wrapper
---

This is a API wrapper written in Golang for the [Astronomy Picture of the Day](https://apod.nasa.gov/apod/astropix.html) service that NASA hosts.

Usage
---

Basic date query:
```go
apodInput := &apod.NewAPODInput{
APIKey: "DEMO_KEY",
}

Apod := apod.NewAPOD(apodInput)
date, _ := time.Parse("2006-01-02", "2022-02-11")
queryInput := &apod.ApodQueryInput{
Date: date,
}

resp, err := Apod.Query(queryInput)
if err != nil {
panic(err)
}

fmt.Println(resp)
```

You can provide a start and end date, with end date defaulting to the current date
```go
apodInput := &apod.NewAPODInput{
APIKey: "DEMO_KEY",
}

Apod := apod.NewAPOD(apodInput)

date, _ := time.Parse("2006-01-02", "2022-02-01")
queryInput := &apod.ApodQueryInput{
StartDate: date,
EndDate: date.Add((time.Hour*24) * 5),
}

resp, err := Apod.Query(queryInput)
if err != nil {
panic(err)
}

fmt.Println(resp)
```

Providing a count gives you that many random selections
```go
apodInput := &apod.NewAPODInput{
APIKey: "DEMO_KEY",
}

Apod := apod.NewAPOD(apodInput)

queryInput := &apod.ApodQueryInput{
Count: 5,
}

resp, err := Apod.Query(queryInput)
if err != nil {
panic(err)
}

fmt.Println(resp)
```