wheretheiss

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: 10 Imported by: 0

Documentation

Overview

Package wheretheiss is the library behind the wheretheiss command line: the HTTP client, request shaping, and the typed data models for the Where The ISS At API (api.wheretheiss.at).

The Client here is the spine every command shares. It sets a real User-Agent, paces requests, and retries transient failures (429, 5xx).

Index

Constants

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

BaseURL is the root every request is built from.

View Source
const Host = "api.wheretheiss.at"

Host is the API hostname this client talks to.

View Source
const ISSID = 25544

ISSID is the NORAD catalog number for the International Space Station.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	BaseURL   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 Where The ISS At API over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func (*Client) CurrentPosition

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

CurrentPosition fetches the live ISS position.

func (*Client) Get

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

Get fetches the URL and returns the response body. It paces and retries according to the client's settings.

func (*Client) HistoricalPositions

func (c *Client) HistoricalPositions(ctx context.Context, timestamps []int64) ([]*Position, error)

HistoricalPositions fetches ISS positions at the given Unix timestamps.

type Config

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

Config holds tuneable settings for the client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns production-ready defaults.

type Domain

type Domain struct{}

Domain is the wheretheiss 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 a resource reference into (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(uriType, id string) (string, error)

Locate returns 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 Position

type Position struct {
	Name       string  `json:"name"       kit:"id"`
	ID         int     `json:"id"`
	Latitude   float64 `json:"latitude"`
	Longitude  float64 `json:"longitude"`
	Altitude   float64 `json:"altitude"`
	Velocity   float64 `json:"velocity"`
	Visibility string  `json:"visibility"`
	Timestamp  int64   `json:"timestamp"`
	Units      string  `json:"units"`
}

Position is a single ISS position record, as returned by the API.

Jump to

Keyboard shortcuts

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