powo

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

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

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "powo-cli/0.1.0"

DefaultUserAgent identifies the client to POWO.

View Source
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

func (c *Client) GetPlant(ctx context.Context, fqID string) (*Plant, error)

GetPlant fetches a single taxon by its IPNI LSID fqId (e.g. "urn:lsid:ipni.org:names:30001404-2").

func (*Client) RecentPlants

func (c *Client) RecentPlants(ctx context.Context, limit int) ([]Plant, error)

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.

func (*Client) SearchPlants

func (c *Client) SearchPlants(ctx context.Context, query string, limit int) ([]Plant, int, error)

SearchPlants queries /search and returns matching plants plus the total count.

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

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

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.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: 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 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.

Jump to

Keyboard shortcuts

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