Documentation
¶
Overview ¶
Package blsgo is a Go interface for getting and parsing data from the BLS.gov API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Calculation ¶
type Calculation struct {
NetChange Change `json:"net_changes"`
PctChange Change `json:"pct_changes"`
}
Calculation represents net and percent change calculations sent with the received data.
type Catalog ¶
type Catalog struct {
Title string `json:"series_title"`
ID string `json:"series_id"`
Season string `json:"seasonality"`
Name string `json:"survey_name"`
Abbr string `json:"survey_abbreviation"`
DataType string `json:"measure_data_type"`
Area string `json:"area"`
AreaType string `json:"area_type"`
}
Catalog represents the catalog data of a series.
type Change ¶
type Change struct {
OneMonth string `json:"1"`
ThreeMonth string `json:"3"`
SixMonth string `json:"6"`
TwelveMonth string `json:"12"`
}
Change represents calculations of change over 1, 3, 6, and 12 months.
type Payload ¶
type Payload struct {
Start string `json:"startyear"`
End string `json:"endyear"`
Series []string `json:"seriesid"`
Catalog bool `json:"catalog,omitempty"`
Calc bool `json:"calculations,omitempty"`
Avg bool `json:"annualaverage,omitempty"`
Key string `json:"registrationkey,omitempty"`
}
Payload defines the structure of data to be sent to the API endpoint. The start year, end year, and series ID are required, but other fields are optional. Catalog, Calc, and Avg have no effect if an API key is not also sent.
type Period ¶
type Period struct {
Year string `json:"year"`
Num string `json:"period"`
Name string `json:"periodName"`
Value string `json:"value"`
Footnotes []Footnote `json:"footnotes"`
Calculations *Calculation `json:"calculations,omitempty"`
}
Period represents an individual period (usually a month) of data.
type ResultData ¶
type ResultData struct {
Status string `json:"status"`
ResponseTime int `json:"responseTime"`
Message []string `json:"message"`
Results Series `json:"Results"`
}
ResultData represents the top-level structure of the received data, including the response status and messages sent by the server.
func GetData ¶
func GetData(payload Payload) (ResultData, error)
GetData takes a Payload, converts it to JSON, and sends it to the specified API endpoint. It returns a ResultData object that contains all the received data for the given Payload. TODO: return errors in an object instead of logging
type Series ¶
type Series struct {
Series []SeriesData `json:"series"`
}
Series represents an array of series.
type SeriesData ¶
type SeriesData struct {
SeriesID string `json:"seriesID"`
Catalog *Catalog `json:"catalog,omitempty"`
Data []Period `json:"data"`
}
SeriesData represents data from a single series.