Skip to content

Latest commit

 

History

History
55 lines (44 loc) · 1.17 KB

README.md

File metadata and controls

55 lines (44 loc) · 1.17 KB

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:

    Apod := apod.NewAPOD("DEMO_KEY")
    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

    Apod := apod.NewAPOD("DEMO_KEY")
    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

    Apod := apod.NewAPOD("DEMO_KEY")
    queryInput := &apod.ApodQueryInput{
        Count: 5,
    }
    
    resp, err := Apod.Query(queryInput)
    if err != nil {
        panic(err)
    }

    fmt.Println(resp)