Documentation
¶
Overview ¶
Package metno exposes the MET Norway weather API as a kit Domain driver. A multi-domain host (ant) enables it with a single blank import:
import _ "github.com/tamnd/metno-cli/metno"
The same Domain also builds the standalone metno binary, so the binary and a host share one source of truth.
Package metno is the library behind the metno command line: the HTTP client, request shaping, and typed data models for the Norwegian Meteorological Institute weather API (api.met.no).
Usage policy: every request MUST carry a meaningful User-Agent header identifying the application and a contact email. The API blocks requests without a proper User-Agent. A rate of 1 req/s is polite and appropriate.
Index ¶
Constants ¶
const Host = "api.met.no"
Host is the API host this client talks to.
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.met.no over HTTP.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults: 1 req/s rate limit, 30s timeout, 3 retries, and the required User-Agent identifying this tool and contact.
type Domain ¶
type Domain struct{}
Domain is the metno driver. It carries no state; the per-run client is built by the factory Register hands to kit.
func (Domain) Classify ¶
Classify turns an input into the canonical (type, id). A "lat,lon" pair (two floats separated by comma) is a "location"; everything else is a "query".
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 WeatherPoint ¶
type WeatherPoint struct {
Time string `kit:"id" json:"time"`
Temperature float64 `json:"temperature"`
WindSpeed float64 `json:"wind_speed"`
WindDir float64 `json:"wind_direction"`
Humidity float64 `json:"humidity"`
CloudCover float64 `json:"cloud_cover"`
Symbol string `json:"symbol"` // from next_1_hours or next_6_hours
Precip1h float64 `json:"precip_1h"` // 0 if not available
}
WeatherPoint is one time-step of a location forecast.