Documentation
¶
Overview ¶
Package powo is the library behind the powo command line: the HTTP client, request shaping, and the typed data models for the Plants of the World Online (POWO) database from Kew Gardens.
The Client here 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. Build your endpoint calls and JSON decoding on top of it.
Index ¶
Constants ¶
const BaseURL = "https://" + Host + "/api/2"
BaseURL is the root every request is built from.
const DefaultUserAgent = "powo-cli/0.1.0"
DefaultUserAgent identifies the client to POWO.
const Host = "powo.science.kew.org"
Host is the POWO site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
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 POWO over HTTP.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client with sensible defaults: a 30s timeout, a 300ms minimum gap between requests, and three retries on transient errors.
func (*Client) GetPlant ¶
GetPlant fetches a single taxon by its IPNI LSID fqId (e.g. "urn:lsid:ipni.org:names:30001404-2").
func (*Client) RecentPlants ¶
RecentPlants returns the most recently listed plants by querying with an empty query (which returns all 1.4M records sorted by name) and limiting the result.
type Domain ¶
type Domain struct{}
Domain is the POWO driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns any accepted input into the canonical (type, id). IPNI LSIDs (starting with "urn:lsid:") are recognised directly; any other non-empty string is treated as a taxon reference too.
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 Plant ¶
type Plant struct {
ID string `json:"id" kit:"id"` // fqId
Name string `json:"name"`
Rank string `json:"rank"`
Accepted bool `json:"accepted"`
Author string `json:"author"`
Kingdom string `json:"kingdom"`
Family string `json:"family"`
Status string `json:"status"` // taxonomicStatus from detail or "Accepted"/"Synonym" from search
PublishedYear int `json:"published_year"`
Lifeforms []string `json:"lifeforms"`
Climates []string `json:"climates"`
}
Plant is one taxon record from the POWO database.