Documentation
¶
Overview ¶
Package bls is the library behind the bls command line: the HTTP client, request shaping, and the typed data models for the Bureau of Labor Statistics (BLS) Public Data 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 site throws under load.
Index ¶
Constants ¶
const Host = "api.bls.gov"
Host is the canonical BLS API host.
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 BLS Public Data API over HTTPS.
func (*Client) MultiSeries ¶
func (c *Client) MultiSeries(ctx context.Context, seriesIDs []string, opts SeriesOptions) ([]*SeriesData, error)
MultiSeries fetches data for multiple series IDs via POST /timeseries/data/.
func (*Client) Series ¶
func (c *Client) Series(ctx context.Context, seriesID string, opts SeriesOptions) (*SeriesData, error)
Series fetches data for a single series via GET /timeseries/data/{seriesId}.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
RegistrationKey string // optional; empty = anonymous tier
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable settings for the BLS client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults for the BLS public API.
type DataPoint ¶
type DataPoint struct {
Year string `json:"year"`
Period string `json:"period"` // M01–M12, Q01–Q04, A01
PeriodName string `json:"period_name"`
Value string `json:"value"`
Footnotes []Footnote `json:"footnotes,omitempty"`
}
DataPoint is one observation in a series.
type Domain ¶
type Domain struct{}
Domain is the BLS driver. It carries no state; the per-run client is built by the factory Register hands kit.
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.
type SeriesData ¶
type SeriesData struct {
SeriesID string `json:"series_id" kit:"id"`
Data []DataPoint `json:"data"`
}
SeriesData is the outer wrapper for one time series response.
type SeriesOptions ¶
type SeriesOptions struct {
StartYear string // e.g. "2022"; empty = BLS default (last 3 years)
EndYear string // e.g. "2023"; empty = BLS default
Latest bool // if true, return only the first (most recent) data point
Limit int // max data points to return; 0 = all
}
SeriesOptions controls filtering for Series and MultiSeries calls.