gleif

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 gleif is the library behind the gleif command line: the HTTP client, request shaping, and the typed data models for the GLEIF LEI (Legal Entity Identifier) 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.

Index

Constants

View Source
const BaseURL = "https://api.gleif.org/api/v1"

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "gleif-cli/0.1 (tamnd87@gmail.com)"

DefaultUserAgent identifies the client to GLEIF. An honest User-Agent is both polite and the thing most likely to keep you unblocked.

View Source
const Host = "api.gleif.org"

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
	UserAgent string
	BaseURL   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 the GLEIF API over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults: a 15s timeout, a 200ms minimum gap between requests, and three retries on transient errors.

func (*Client) Get

func (c *Client) Get(ctx context.Context, u string) ([]byte, error)

Get fetches u and returns the response body. It paces and retries according to the client's settings. The caller owns nothing extra; the body is read fully and closed here.

func (*Client) GetByLEI

func (c *Client) GetByLEI(ctx context.Context, lei string) (*Entity, error)

GetByLEI fetches a single entity by its LEI code.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, pageSize, page int) ([]Entity, error)

Search searches for entities by full-text query.

func (*Client) SearchByName

func (c *Client) SearchByName(ctx context.Context, name string) ([]Entity, error)

SearchByName searches for entities by exact legal name.

type Domain

type Domain struct{}

Domain is the gleif 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). A 20-character all-caps alphanumeric string is treated as a LEI code. Anything else is treated as a search query.

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 Entity

type Entity struct {
	LEI          string `kit:"id" json:"lei"`
	Name         string `json:"name"`
	Country      string `json:"country"`
	Region       string `json:"region"`
	City         string `json:"city"`
	Jurisdiction string `json:"jurisdiction"`
	Category     string `json:"category"`
	Status       string `json:"status"`
	InitialDate  string `json:"initial_date"`
	LastUpdate   string `json:"last_update"`
	NextRenewal  string `json:"next_renewal"`
}

Entity is one legal entity record from the GLEIF LEI registry.

Jump to

Keyboard shortcuts

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