whogho

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

Documentation

Overview

Package whogho is the library behind the whogho command line: the HTTP client, request shaping, and the typed data models for the WHO Global Health Observatory (GHO) OData API.

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 Host = "ghoapi.azureedge.net"

Host is the base hostname for the WHO GHO OData API.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the WHO GHO OData API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Countries

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

Countries lists all WHO GHO country dimension values.

func (*Client) GetData

func (c *Client) GetData(ctx context.Context, indicatorCode, country string, year int, dim1 string, limit int) ([]DataPoint, error)

GetData retrieves data points for a given indicator, optionally filtering by country code, year, Dim1 value, and limiting the number of results.

func (*Client) Indicators

func (c *Client) Indicators(ctx context.Context, search string, limit int) ([]Indicator, error)

Indicators lists all indicators, optionally filtered by name search and limited.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tuneable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible production defaults.

type Country

type Country struct {
	Code   string `json:"code"`
	Name   string `json:"name"`
	Region string `json:"region,omitempty"`
}

Country is a WHO GHO country (spatial dimension) value.

type DataPoint

type DataPoint struct {
	Indicator  string   `json:"indicator"`
	Country    string   `json:"country,omitempty"` // SpatialDim
	Year       int      `json:"year,omitempty"`    // TimeDim
	Value      *float64 `json:"value"`             // NumericValue, nil if missing
	Low        *float64 `json:"low,omitempty"`
	High       *float64 `json:"high,omitempty"`
	Dimension1 string   `json:"dimension1,omitempty"` // Dim1 (e.g. SEX_BTSX)
	Comments   string   `json:"comments,omitempty"`
}

DataPoint is a single observation from the WHO GHO data.

type Domain

type Domain struct{}

Domain is the whogho driver.

func (Domain) Classify

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

Classify turns an indicator code or URL into a (type, id) pair.

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 canonical API 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 Indicator

type Indicator struct {
	Code     string `json:"IndicatorCode"`
	Name     string `json:"IndicatorName"`
	URL      string `json:"IndicatorUrl,omitempty"`
	Language string `json:"Language,omitempty"`
}

Indicator is a WHO GHO indicator definition.

Jump to

Keyboard shortcuts

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