jplsbdb

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 jplsbdb is the library behind the jplsbdb command line: the HTTP client, request shaping, and the typed data models for the JPL Small-Body Database API (ssd-api.jpl.nasa.gov).

The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load. Build your endpoint calls and JSON decoding on top of it.

Index

Constants

View Source
const BaseURL = "https://" + Host

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "jplsbdb-cli/dev (+https://github.com/tamnd/jplsbdb-cli)"

DefaultUserAgent identifies the client to the JPL API. A real, honest User-Agent is both polite and the thing most likely to keep you unblocked.

View Source
const Host = "ssd-api.jpl.nasa.gov"

Host is the site this client talks to, and the host the URI driver in domain.go claims.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	// Rate is the minimum gap between requests. Zero means no pacing.
	Rate    time.Duration
	Retries int
	// contains filtered or unexported fields
}

Client talks to the JPL Small-Body Database API over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults: a 30s timeout, a 500ms minimum gap between requests, and five retries on transient errors.

func (*Client) GetCloseApproaches

func (c *Client) GetCloseApproaches(ctx context.Context, dateMin, dateMax, distMax string, limit int) ([]*CloseApproach, error)

GetCloseApproaches fetches close-approach records.

func (*Client) GetFireballs

func (c *Client) GetFireballs(ctx context.Context, dateMin string, limit int) ([]*Fireball, error)

GetFireballs fetches fireball event records.

func (*Client) GetSmallBody

func (c *Client) GetSmallBody(ctx context.Context, query string) (*SmallBody, error)

GetSmallBody fetches one small body by name or designation.

type CloseApproach

type CloseApproach struct {
	Designation string `kit:"id" json:"designation"`
	Date        string `json:"date"`          // cd field e.g. "2024-Jan-01 02:47"
	Distance    string `json:"distance_au"`   // dist in AU
	VelocityKms string `json:"velocity_km_s"` // v-inf
	HMagnitude  string `json:"h_magnitude"`   // h
	FullName    string `json:"full_name"`
}

CloseApproach holds the key fields from one close-approach record.

type Config

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

Config holds overrides for NewClient fields.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the suggested defaults.

type Domain

type Domain struct{}

Domain is the jplsbdb driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any accepted input into the canonical (type, id). Purely numeric or "N Name" style inputs map to "body"; date-like inputs map to "date".

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(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

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

Register installs the client factory and every operation onto app.

type Fireball

type Fireball struct {
	Date     string `kit:"id" json:"date"`
	Energy   string `json:"energy_gwh"`       // energy field (GWh)
	ImpactE  string `json:"impact_energy_kt"` // impact-e (kt)
	Lat      string `json:"lat"`
	Lon      string `json:"lon"`
	Altitude string `json:"altitude_km"`
	Velocity string `json:"velocity_km_s"`
}

Fireball holds the key fields from one fireball event record.

type SmallBody

type SmallBody struct {
	FullName      string `kit:"id" json:"full_name"`
	ShortName     string `json:"short_name"`
	OrbitClass    string `json:"orbit_class"`
	SPKID         string `json:"spk_id"`
	Eccentricity  string `json:"eccentricity"`    // from elements where name=="e"
	SemiMajorAxis string `json:"semi_major_axis"` // from elements where name=="a"
	HMagnitude    string `json:"h_magnitude"`     // from phys_par where name=="H"
}

SmallBody holds the key fields from an SBDB object lookup.

Jump to

Keyboard shortcuts

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