nager

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

Documentation

Overview

Package nager is the library behind the nager command line: the HTTP client, request shaping, and the typed data models for the Nager.Date public holiday API (date.nager.at).

No API key or authentication is required. The API provides public holiday data for 123 countries.

Index

Constants

View Source
const (
	// DefaultUserAgent identifies the client to the server.
	DefaultUserAgent = "nager-cli/dev (+https://github.com/tamnd/nager-cli)"

	// Host is the site this client talks to.
	Host = "date.nager.at"
)

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 Nager.Date 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) ([]Country, error)

Countries returns all available countries supported by the API.

func (*Client) Holidays

func (c *Client) Holidays(ctx context.Context, year int, countryCode string, limit int) ([]Holiday, error)

Holidays fetches public holidays for the given country and year. Pass limit=0 for all results.

func (*Client) Next

func (c *Client) Next(ctx context.Context, countryCode string, limit int) ([]Holiday, error)

Next fetches upcoming public holidays (next 365 days) for the given country. Pass limit=0 for all results.

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 a Config with sensible defaults for the Nager.Date API.

type Country

type Country struct {
	Rank        int    `json:"rank"`
	CountryCode string `kit:"id" json:"country_code"`
	Name        string `json:"name"`
}

Country is one supported country returned by the AvailableCountries endpoint.

type Domain

type Domain struct{}

Domain is the nager driver.

func (Domain) Classify

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

Classify turns an input 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.

func (Domain) Locate

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

Locate returns 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 Holiday

type Holiday struct {
	Rank        int    `json:"rank"`
	Date        string `kit:"id" json:"date"`
	Name        string `json:"name"`
	LocalName   string `json:"local_name"`
	CountryCode string `json:"country_code"`
	Global      bool   `json:"global"`
	Types       string `json:"types"` // comma-joined list from the API (e.g. "Public")
}

Holiday is one public holiday record returned by Nager.Date.

Jump to

Keyboard shortcuts

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