opennotify

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

Documentation

Overview

Package opennotify is the library behind the opennotify command line: the HTTP client, request shaping, and the typed data models for the Open Notify API (api.open-notify.org).

The API is completely open: no authentication, no API key. It exposes two endpoints — the current ISS position and the list of people in space. The API is HTTP-only; HTTPS is not supported.

Index

Constants

View Source
const Host = "api.open-notify.org"

Host is the API hostname.

Variables

This section is empty.

Functions

This section is empty.

Types

type Astronaut

type Astronaut struct {
	Name  string `kit:"id" json:"name"`
	Craft string `json:"craft"`
}

Astronaut is one person currently in space.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the Open Notify API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Astronauts

func (c *Client) Astronauts(ctx context.Context) ([]Astronaut, error)

Astronauts returns all humans currently in space.

func (*Client) Position

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

Position returns the current position of the International Space Station.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration // minimum gap between consecutive HTTP requests
	Timeout   time.Duration // per-request HTTP timeout
	Retries   int           // maximum retry attempts on transient errors
}

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults for the Open Notify API.

type Domain

type Domain struct{}

Domain is the opennotify driver.

func (Domain) Classify

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

Classify turns an input into the canonical (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 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 {
	Latitude  string `kit:"id" json:"latitude"`
	Longitude string `json:"longitude"`
	Timestamp int64  `json:"timestamp"`
}

Position holds the current coordinates of the ISS.

Jump to

Keyboard shortcuts

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