spacedevs

package
v0.1.0 Latest Latest
Warning

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

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

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

View Source
const BaseURL = "https://ll.thespacedevs.com/2.2.0"

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "spacedevs-cli/0.1 (tamnd87@gmail.com)"

DefaultUserAgent identifies the client to the API.

View Source
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 NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) ([]byte, error)

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

func (c *Client) ListAgencies(ctx context.Context, limit int, agencyType string) ([]*Agency, error)

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

func (c *Client) ListLaunches(ctx context.Context, limit int, search string) ([]*Launch, error)

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.

func (*Client) ListUpcoming

func (c *Client) ListUpcoming(ctx context.Context, limit int, search string) ([]*Launch, error)

ListUpcoming returns upcoming rocket launches.

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.

func (Domain) Register

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

Register installs the client factory and every operation onto app.

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.

type Spacecraft

type Spacecraft struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Status      string `json:"status"`
	Type        string `json:"type"`
	Agency      string `json:"agency"`
	Description string `json:"description"`
}

Spacecraft is a spacecraft record.

Jump to

Keyboard shortcuts

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