nasaneo

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package nasaneo exposes the NASA NeoWs near-Earth object API as a kit Domain driver.

A multi-domain host (ant) enables it with a single blank import:

import _ "github.com/tamnd/nasaneo-cli/nasaneo"

The same Domain also builds the standalone neo binary (see cli.NewApp).

Package nasaneo is the library behind the neo command line: the HTTP client, request shaping, and typed data models for NASA's Near Earth Object Web Service (NeoWs) at api.nasa.gov/neo/rest/v1.

NeoWs provides information on near-Earth asteroids: estimated diameters, close approach distances, velocity, and hazard classification. Requires an api_key (DEMO_KEY for testing; register at api.nasa.gov for 1000/hr).

Index

Constants

View Source
const Host = "api.nasa.gov"

Host is the API host this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the NASA NeoWs API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Browse

func (c *Client) Browse(ctx context.Context, page, size int) ([]NEO, error)

Browse fetches a page of NEOs from the full catalog.

func (*Client) Feed

func (c *Client) Feed(ctx context.Context, start, end string) ([]NEO, error)

Feed fetches near-Earth objects for a date range (max 7 days). Results are flattened and sorted by date then name.

func (*Client) Get

func (c *Client) Get(ctx context.Context, id string) (*NEO, error)

Get fetches a single NEO by asteroid ID.

func (*Client) Stats

func (c *Client) Stats(ctx context.Context) (*Stats, error)

Stats fetches the total NEO database counts.

type Config

type Config struct {
	BaseURL   string
	APIKey    string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the nasaneo driver.

func (Domain) Classify

func (Domain) Classify(input string) (string, string, error)

Classify turns any input into the canonical (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(t, id string) (string, error)

Locate returns the NASA JPL URL for a NEO by ID.

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type NEO

type NEO struct {
	ID                string  `json:"id"`
	Name              string  `json:"name"`
	Hazardous         bool    `json:"hazardous"`
	MagnitudeH        float64 `json:"magnitude_h"`
	DiamMinKm         float64 `json:"diam_min_km"`
	DiamMaxKm         float64 `json:"diam_max_km"`
	CloseApproachDate string  `json:"close_approach_date"`
	MissDistAU        string  `json:"miss_dist_au"`
	MissDistLunar     string  `json:"miss_dist_lunar"`
	MissDistKm        string  `json:"miss_dist_km"`
	VelocityKPS       string  `json:"velocity_kps"`
	URL               string  `json:"url"`
}

NEO is a near-Earth asteroid record.

type Stats

type Stats struct {
	NEOCount           int `json:"neo_count"`
	CloseApproachCount int `json:"close_approach_count"`
}

Stats holds the total NEO database counts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL