Documentation
¶
Overview ¶
Package noaatides is the library behind the noaa-tides command line: the HTTP client, request shaping, and the typed data models for the NOAA Tides and Currents API (api.tidesandcurrents.noaa.gov).
The Client 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.
Index ¶
- Constants
- type Client
- func (c *Client) AirTemperature(ctx context.Context, station, beginDate, endDate string) ([]*Observation, error)
- func (c *Client) Predictions(ctx context.Context, station, beginDate, endDate string) ([]*Prediction, error)
- func (c *Client) Stations(ctx context.Context, limit int) ([]*Station, error)
- func (c *Client) WaterLevel(ctx context.Context, station, beginDate, endDate, datum string) ([]*Observation, error)
- type Config
- type Domain
- type Observation
- type Prediction
- type Station
Constants ¶
const Host = "api.tidesandcurrents.noaa.gov"
Host is the primary API host.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to api.tidesandcurrents.noaa.gov over HTTP.
func (*Client) AirTemperature ¶
func (c *Client) AirTemperature(ctx context.Context, station, beginDate, endDate string) ([]*Observation, error)
AirTemperature fetches observed air temperature data for a station over a date range.
func (*Client) Predictions ¶
func (c *Client) Predictions(ctx context.Context, station, beginDate, endDate string) ([]*Prediction, error)
Predictions fetches hi/lo tide predictions for a station over a date range.
func (*Client) WaterLevel ¶
func (c *Client) WaterLevel(ctx context.Context, station, beginDate, endDate, datum string) ([]*Observation, error)
WaterLevel fetches observed water level data for a station over a date range.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tuneable parameters for a Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the production configuration for the NOAA Tides API.
type Domain ¶
type Domain struct{}
Domain is the NOAA Tides driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns a station ID or stationhome URL 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.
type Observation ¶
type Observation struct {
Station string `kit:"id" json:"station"` // from metadata.id or query param
Time string `json:"time"`
Value float64 `json:"value"`
Quality string `json:"quality"` // q field or "predicted"
}
Observation is one time-stamped measurement (water level, air temperature, etc.).