openfigi

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 openfigi is the library behind the openfigi command line: the HTTP client, request shaping, and the typed data models for the OpenFIGI financial instrument identifier API.

The Client paces requests so a busy session stays inside the unauthenticated rate limit (25 req/min), retries transient failures (429, 5xx), and exposes two methods that cover the two live endpoints: Map and Search.

Index

Constants

View Source
const DefaultUserAgent = "openfigi/dev (+https://github.com/tamnd/openfigi-cli)"

DefaultUserAgent identifies the client to OpenFIGI.

View Source
const Host = "openfigi.com"

Host is the site this client's domain driver claims.

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 OpenFIGI API over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with the default config applied.

func (*Client) Map

func (c *Client) Map(ctx context.Context, idType, idValue, exchCode string) ([]Instrument, error)

Map maps an identifier to FIGI records using POST /v3/mapping.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query, exchCode string, limit int) ([]Instrument, error)

Search searches for instruments using POST /v3/search. The limit is applied client-side after the API returns its page of results.

type Config

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

Config holds tunable Client parameters.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns conservative defaults for unauthenticated access. The unauthenticated rate limit is 25 req/min, so we pace at 1s per request.

type Domain

type Domain struct{}

Domain is the openfigi 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 (uriType, id).

  • Starts with "BBG" -> ("figi", input)
  • Matches ISIN pattern -> ("isin", input)
  • Else -> ("query", input)

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 (uriType, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Instrument

type Instrument struct {
	FIGI          string `kit:"id" json:"figi"`
	Name          string `json:"name"`
	Ticker        string `json:"ticker"`
	ExchCode      string `json:"exch_code"`
	SecurityType  string `json:"security_type"`
	MarketSector  string `json:"market_sector"`
	CompositeFIGI string `json:"composite_figi"`
}

Instrument is the output record for both Map and Search operations.

Jump to

Keyboard shortcuts

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