Documentation
¶
Overview ¶
Package spacedevs is the library behind the spacedevs command line: the HTTP client, request shaping, and the typed data models for The Space Devs Launch Library 2 API at ll.thespacedevs.com.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite (15 req/hour anonymous limit), and retries transient failures (429 and 5xx).
Index ¶
- Constants
- type Agency
- type Astronaut
- type Client
- func (c *Client) Get(ctx context.Context, url string) ([]byte, error)
- func (c *Client) ListAgencies(ctx context.Context, limit int, agencyType string) ([]*Agency, error)
- func (c *Client) ListAstronauts(ctx context.Context, limit int, search string) ([]*Astronaut, error)
- func (c *Client) ListLaunches(ctx context.Context, limit int, search string) ([]*Launch, error)
- func (c *Client) ListSpacecraft(ctx context.Context, limit int, search string) ([]*Spacecraft, error)
- func (c *Client) ListUpcoming(ctx context.Context, limit int, search string) ([]*Launch, error)
- type Config
- type Domain
- type Launch
- type Spacecraft
Constants ¶
const BaseURL = "https://ll.thespacedevs.com/2.2.0"
BaseURL is the root every request is built from.
const DefaultUserAgent = "spacedevs-cli/0.1 (tamnd87@gmail.com)"
DefaultUserAgent identifies the client to the API.
const Host = "ll.thespacedevs.com"
Host is the API hostname.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agency ¶
type Agency struct {
ID int `json:"id"`
Name string `json:"name"`
Abbrev string `json:"abbrev"`
Type string `json:"type"`
CountryCode string `json:"country_code"`
Website string `json:"website"`
Description string `json:"description"`
}
Agency is a space agency or organization.
type Astronaut ¶
type Astronaut struct {
ID int `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Agency string `json:"agency"`
Nationality string `json:"nationality"`
DOB string `json:"dob"`
FlightCount int `json:"flight_count"`
Bio string `json:"bio"`
}
Astronaut is a space traveler record.
type Client ¶
type Client struct {
HTTP *http.Client
BaseURL string
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 Space Devs Launch Library 2 API.
func (*Client) Get ¶
Get fetches url and returns the response body. It paces and retries according to the client's settings. The caller owns nothing extra; the body is read fully and closed here.
func (*Client) ListAgencies ¶
ListAgencies returns space agencies and organizations.
func (*Client) ListAstronauts ¶
func (c *Client) ListAstronauts(ctx context.Context, limit int, search string) ([]*Astronaut, error)
ListAstronauts returns astronauts/space travelers.
func (*Client) ListLaunches ¶
ListLaunches returns all launches (past and upcoming).
func (*Client) ListSpacecraft ¶
func (c *Client) ListSpacecraft(ctx context.Context, limit int, search string) ([]*Spacecraft, error)
ListSpacecraft returns spacecraft records.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds tunable knobs.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns safe defaults for anonymous access. The API rate-limits anonymous users to 15 req/hour; 4s between requests keeps typical usage well within that budget.
type Domain ¶
type Domain struct{}
Domain is the Space Devs driver. It carries no state; the per-run client is built by the factory Register hands kit.
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 Launch ¶
type Launch struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
NET string `json:"net"`
WindowStart string `json:"window_start"`
WindowEnd string `json:"window_end"`
Probability int `json:"probability"`
Rocket string `json:"rocket"`
Mission string `json:"mission"`
MissionType string `json:"mission_type"`
Orbit string `json:"orbit"`
Pad string `json:"pad"`
Location string `json:"location"`
Provider string `json:"provider"`
}
Launch is a rocket launch event.