openligadb

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

Documentation

Overview

Package openligadb is the library behind the openligadb command line: the HTTP client, request shaping, and the typed data models for the OpenLigaDB API (German football statistics).

The Client 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.

Index

Constants

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

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "openligadb-cli/0.1.0 (github.com/tamnd/openligadb-cli)"

DefaultUserAgent identifies the client to OpenLigaDB.

View Source
const Host = "api.openligadb.de"

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 {
	HTTP      *http.Client
	BaseURL   string
	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 OpenLigaDB over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func NewClientFromConfig

func NewClientFromConfig(cfg Config) *Client

NewClientFromConfig returns a Client configured from cfg.

func (*Client) Groups

func (c *Client) Groups(ctx context.Context, league, season string) ([]Group, error)

Groups returns all match days/groups for a league season.

func (*Client) Leagues

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

Leagues returns all available leagues.

func (*Client) Matches

func (c *Client) Matches(ctx context.Context, league, season string, day, limit int) ([]Match, error)

Matches returns matches for a league season. If day > 0, only that match day is returned.

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 for the client.

type Domain

type Domain struct{}

Domain is the OpenLigaDB driver.

func (Domain) Classify

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

Classify turns any accepted input into the canonical (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, 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 Group

type Group struct {
	Name    string `json:"name"`
	OrderID int    `json:"order_id"`
}

Group represents a match day / group in a league season.

type League

type League struct {
	ID       int    `json:"leagueId"`
	Name     string `json:"leagueName"`
	Shortcut string `json:"leagueShortcut"`
	Season   string `json:"leagueSeason"`
}

League represents an available league in OpenLigaDB.

type Match

type Match struct {
	ID         int    `json:"match_id"`
	DateTime   string `json:"match_datetime"`
	Home       string `json:"home_team"`
	Away       string `json:"away_team"`
	Group      string `json:"group"`
	ScoreHalf  string `json:"score_halftime,omitempty"`
	ScoreFinal string `json:"score_final,omitempty"`
	Finished   bool   `json:"finished"`
}

Match is the flattened match record we emit.

Jump to

Keyboard shortcuts

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