Skip to content

HelixSpiral/apod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Astronomy Picture of the Day API Wrapper

This is a API wrapper written in Golang for the Astronomy Picture of the Day service that NASA hosts.

Usage

Basic date query:

    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

    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

    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)