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
- type Client
- func (c *Client) GetCloseApproaches(ctx context.Context, dateMin, dateMax, distMax string, limit int) ([]*CloseApproach, error)
- func (c *Client) GetFireballs(ctx context.Context, dateMin string, limit int) ([]*Fireball, error)
- func (c *Client) GetSmallBody(ctx context.Context, query string) (*SmallBody, error)
- type CloseApproach
- type Config
- type Domain
- type Fireball
- type SmallBody
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
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.
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 ¶
GetFireballs fetches fireball event records.
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 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 ¶
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.
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.