Documentation
¶
Overview ¶
Package fred provides a client for the Federal Reserve Economic Data (FRED) API.
It covers all 34 FRED API endpoints. Zero dependencies beyond Go stdlib.
Usage:
client, err := fred.New(fred.WithAPIKey("your-key"))
if err != nil {
log.Fatal(err)
}
obs, err := client.GetSeriesObservations(ctx, "DGS20")
Index ¶
- type APIError
- type Category
- type Client
- func (c *Client) GetCategory(ctx context.Context, id int) (*Category, error)
- func (c *Client) GetCategoryChildren(ctx context.Context, id int) ([]Category, error)
- func (c *Client) GetCategoryRelated(ctx context.Context, id int) ([]Category, error)
- func (c *Client) GetCategoryRelatedTags(ctx context.Context, id int, tagNames []string, opts ...TagOption) ([]Tag, error)
- func (c *Client) GetCategorySeries(ctx context.Context, categoryID int, opts ...SearchOption) ([]SearchResult, error)
- func (c *Client) GetCategoryTags(ctx context.Context, id int, opts ...TagOption) ([]Tag, error)
- func (c *Client) GetRegionalData(ctx context.Context, opts ...RegionalDataOption) (*MapData, error)
- func (c *Client) GetRelatedTags(ctx context.Context, tagNames []string, opts ...TagOption) ([]Tag, error)
- func (c *Client) GetRelease(ctx context.Context, id int) (*Release, error)
- func (c *Client) GetReleaseDates(ctx context.Context, id int, opts ...ReleaseDateOption) ([]ReleaseDate, error)
- func (c *Client) GetReleaseRelatedTags(ctx context.Context, id int, tagNames []string, opts ...TagOption) ([]Tag, error)
- func (c *Client) GetReleaseSeries(ctx context.Context, releaseID int, opts ...SearchOption) ([]SearchResult, error)
- func (c *Client) GetReleaseSources(ctx context.Context, id int) ([]Source, error)
- func (c *Client) GetReleaseTables(ctx context.Context, id int, opts ...TableOption) ([]ReleaseTableElement, error)
- func (c *Client) GetReleaseTags(ctx context.Context, id int, opts ...TagOption) ([]Tag, error)
- func (c *Client) GetReleases(ctx context.Context, opts ...ReleaseListOption) ([]Release, error)
- func (c *Client) GetReleasesDates(ctx context.Context, opts ...ReleaseDateOption) ([]ReleaseDate, error)
- func (c *Client) GetSeriesAllReleases(ctx context.Context, seriesID string, opts ...ObservationOption) ([]Observation, error)
- func (c *Client) GetSeriesAsOf(ctx context.Context, seriesID string, asOf time.Time, ...) ([]Observation, error)
- func (c *Client) GetSeriesCategories(ctx context.Context, seriesID string) ([]Category, error)
- func (c *Client) GetSeriesData(ctx context.Context, seriesID string, opts ...MapDataOption) (*MapData, error)
- func (c *Client) GetSeriesFirstRelease(ctx context.Context, seriesID string, opts ...ObservationOption) ([]Observation, error)
- func (c *Client) GetSeriesGroup(ctx context.Context, seriesID string) (*SeriesGroup, error)
- func (c *Client) GetSeriesInfo(ctx context.Context, seriesID string) (*Series, error)
- func (c *Client) GetSeriesObservations(ctx context.Context, seriesID string, opts ...ObservationOption) ([]Observation, error)
- func (c *Client) GetSeriesRelease(ctx context.Context, seriesID string) (*Release, error)
- func (c *Client) GetSeriesTags(ctx context.Context, seriesID string, opts ...TagOption) ([]Tag, error)
- func (c *Client) GetSeriesUpdates(ctx context.Context, opts ...UpdateOption) ([]SearchResult, error)
- func (c *Client) GetSeriesVintageDates(ctx context.Context, seriesID string, opts ...ObservationOption) ([]time.Time, error)
- func (c *Client) GetSource(ctx context.Context, id int) (*Source, error)
- func (c *Client) GetSourceReleases(ctx context.Context, id int, opts ...ReleaseListOption) ([]Release, error)
- func (c *Client) GetSources(ctx context.Context, opts ...SourceOption) ([]Source, error)
- func (c *Client) GetTags(ctx context.Context, opts ...TagOption) ([]Tag, error)
- func (c *Client) GetTagsSeries(ctx context.Context, tagNames []string, opts ...SearchOption) ([]SearchResult, error)
- func (c *Client) SearchSeries(ctx context.Context, text string, opts ...SearchOption) ([]SearchResult, error)
- func (c *Client) SearchSeriesRelatedTags(ctx context.Context, text string, tagNames []string, opts ...TagOption) ([]Tag, error)
- func (c *Client) SearchSeriesTags(ctx context.Context, text string, opts ...TagOption) ([]Tag, error)
- type ClientOption
- type MapData
- type MapDataEntry
- type MapDataOption
- type Observation
- type ObservationOption
- func WithAggregationMethod(m string) ObservationOption
- func WithFrequency(f string) ObservationOption
- func WithObservationEnd(t time.Time) ObservationOption
- func WithObservationLimit(n int) ObservationOption
- func WithObservationOffset(n int) ObservationOption
- func WithObservationSortOrder(o SortOrder) ObservationOption
- func WithObservationStart(t time.Time) ObservationOption
- func WithOutputType(t int) ObservationOption
- func WithRealtimeEnd(t time.Time) ObservationOption
- func WithRealtimeStart(t time.Time) ObservationOption
- func WithUnits(u string) ObservationOption
- func WithVintageDates(dates ...string) ObservationOption
- type OrderBy
- type RegionalDataOption
- func WithMapUnits(u string) RegionalDataOption
- func WithRegionType(t string) RegionalDataOption
- func WithRegionalDate(d string) RegionalDataOption
- func WithRegionalFrequency(f string) RegionalDataOption
- func WithSeason(s string) RegionalDataOption
- func WithSeriesGroup(g string) RegionalDataOption
- func WithTransformation(t string) RegionalDataOption
- type Release
- type ReleaseDate
- type ReleaseDateOption
- type ReleaseListOption
- type ReleaseTableElement
- type SearchOption
- func WithExcludeTags(tags ...string) SearchOption
- func WithFilter(variable, value string) SearchOption
- func WithLimit(n int) SearchOption
- func WithOrderBy(ob OrderBy) SearchOption
- func WithSearchType(t string) SearchOption
- func WithSortOrder(o SortOrder) SearchOption
- func WithTagNames(tags ...string) SearchOption
- type SearchResult
- type Series
- type SeriesGroup
- type SortOrder
- type Source
- type SourceOption
- type TableOption
- type Tag
- type TagOption
- func WithTagGroupID(g string) TagOption
- func WithTagLimit(n int) TagOption
- func WithTagOrderBy(ob OrderBy) TagOption
- func WithTagSearchText(text string) TagOption
- func WithTagSetExclude(tags ...string) TagOption
- func WithTagSetNames(tags ...string) TagOption
- func WithTagSortOrder(o SortOrder) TagOption
- type UpdateOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category struct {
ID int `json:"id"`
Name string `json:"name"`
ParentID int `json:"parent_id"`
Notes string `json:"notes,omitempty"`
}
Category represents a FRED category.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a FRED API client. Must be constructed via New. Safe for concurrent use by multiple goroutines.
API key resolution order:
- WithAPIKey("...")
- $FRED_API_KEY environment variable
func (*Client) GetCategory ¶
GetCategory returns information about a FRED category. Endpoint: GET /fred/category?category_id={id}
func (*Client) GetCategoryChildren ¶
GetCategoryChildren returns the child categories for a given FRED category. Endpoint: GET /fred/category/children?category_id={id}
func (*Client) GetCategoryRelated ¶
GetCategoryRelated returns related categories for a given FRED category. Endpoint: GET /fred/category/related?category_id={id}
func (*Client) GetCategoryRelatedTags ¶
func (c *Client) GetCategoryRelatedTags(ctx context.Context, id int, tagNames []string, opts ...TagOption) ([]Tag, error)
GetCategoryRelatedTags returns related tags for a FRED category. Endpoint: GET /fred/category/related_tags?category_id={id}&tag_names={tags}
func (*Client) GetCategorySeries ¶
func (c *Client) GetCategorySeries(ctx context.Context, categoryID int, opts ...SearchOption) ([]SearchResult, error)
GetCategorySeries returns series belonging to a category. Auto-paginates. Limit 0 = unlimited. Default limit = 0. Endpoint: GET /fred/category/series?category_id={id}
func (*Client) GetCategoryTags ¶
GetCategoryTags returns the tags for a FRED category. Endpoint: GET /fred/category/tags?category_id={id}
func (*Client) GetRegionalData ¶
GetRegionalData returns GeoFRED regional data for a series group and region type. Endpoint: GET /geofred/regional/data
func (*Client) GetRelatedTags ¶
func (c *Client) GetRelatedTags(ctx context.Context, tagNames []string, opts ...TagOption) ([]Tag, error)
GetRelatedTags returns related tags for given tag names. Endpoint: GET /fred/related_tags?tag_names={tags}
func (*Client) GetRelease ¶
GetRelease returns information about a FRED release. Endpoint: GET /fred/release?release_id={id}
func (*Client) GetReleaseDates ¶
func (c *Client) GetReleaseDates(ctx context.Context, id int, opts ...ReleaseDateOption) ([]ReleaseDate, error)
GetReleaseDates returns release dates for a specific FRED release. Endpoint: GET /fred/release/dates?release_id={id}
func (*Client) GetReleaseRelatedTags ¶
func (c *Client) GetReleaseRelatedTags(ctx context.Context, id int, tagNames []string, opts ...TagOption) ([]Tag, error)
GetReleaseRelatedTags returns related tags for a FRED release. Endpoint: GET /fred/release/related_tags?release_id={id}&tag_names={tags}
func (*Client) GetReleaseSeries ¶
func (c *Client) GetReleaseSeries(ctx context.Context, releaseID int, opts ...SearchOption) ([]SearchResult, error)
GetReleaseSeries returns series belonging to a release. Auto-paginates. Limit 0 = unlimited. Default limit = 0. Endpoint: GET /fred/release/series?release_id={id}
func (*Client) GetReleaseSources ¶
GetReleaseSources returns the sources for a FRED release. Endpoint: GET /fred/release/sources?release_id={id}
func (*Client) GetReleaseTables ¶
func (c *Client) GetReleaseTables(ctx context.Context, id int, opts ...TableOption) ([]ReleaseTableElement, error)
GetReleaseTables returns the release table for a FRED release. Endpoint: GET /fred/release/tables?release_id={id}
func (*Client) GetReleaseTags ¶
GetReleaseTags returns the tags for a FRED release. Endpoint: GET /fred/release/tags?release_id={id}
func (*Client) GetReleases ¶
GetReleases returns all FRED releases. Endpoint: GET /fred/releases
func (*Client) GetReleasesDates ¶
func (c *Client) GetReleasesDates(ctx context.Context, opts ...ReleaseDateOption) ([]ReleaseDate, error)
GetReleasesDates returns release dates for all FRED releases. Endpoint: GET /fred/releases/dates
func (*Client) GetSeriesAllReleases ¶
func (c *Client) GetSeriesAllReleases(ctx context.Context, seriesID string, opts ...ObservationOption) ([]Observation, error)
GetSeriesAllReleases returns all observations including every revision. Defaults realtime_start="1776-07-04", realtime_end="9999-12-31" unless overridden by ObservationOption. Uses the same endpoint as GetSeriesObservations.
func (*Client) GetSeriesAsOf ¶
func (c *Client) GetSeriesAsOf(ctx context.Context, seriesID string, asOf time.Time, opts ...ObservationOption) ([]Observation, error)
GetSeriesAsOf returns data as known on a specific date. Calls GetSeriesObservations with realtime_end=asOf.
func (*Client) GetSeriesCategories ¶
GetSeriesCategories returns categories for a FRED series. Endpoint: GET /fred/series/categories?series_id={id}
func (*Client) GetSeriesData ¶
func (c *Client) GetSeriesData(ctx context.Context, seriesID string, opts ...MapDataOption) (*MapData, error)
GetSeriesData returns GeoFRED series data for regional maps. Endpoint: GET /geofred/series/data?series_id={id}
func (*Client) GetSeriesFirstRelease ¶
func (c *Client) GetSeriesFirstRelease(ctx context.Context, seriesID string, opts ...ObservationOption) ([]Observation, error)
GetSeriesFirstRelease returns the first published value for each date. Calls GetSeriesAllReleases and groups by Date, picking the earliest RealtimeStart for each Date.
func (*Client) GetSeriesGroup ¶
GetSeriesGroup returns the GeoFRED series group metadata for a series. Endpoint: GET /geofred/series/group?series_id={id}
func (*Client) GetSeriesInfo ¶
GetSeriesInfo returns metadata for a FRED series. Endpoint: GET /fred/series?series_id={id}
func (*Client) GetSeriesObservations ¶
func (c *Client) GetSeriesObservations(ctx context.Context, seriesID string, opts ...ObservationOption) ([]Observation, error)
GetSeriesObservations returns data values for a series. Endpoint: GET /fred/series/observations?series_id={id} Does not auto-paginate — FRED returns up to 100,000 observations per request.
Example ¶
client, _ := fred.New(fred.WithAPIKey("your-key"))
obs, _ := client.GetSeriesObservations(context.Background(), "DGS20",
fred.WithObservationStart(time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)),
)
for _, o := range obs {
if !o.IsNA {
fmt.Printf("%s: %.2f\n", o.Date.Format("2006-01-02"), o.Value)
}
}
func (*Client) GetSeriesRelease ¶
GetSeriesRelease returns the release for a FRED series. Endpoint: GET /fred/series/release?series_id={id}
func (*Client) GetSeriesTags ¶
func (c *Client) GetSeriesTags(ctx context.Context, seriesID string, opts ...TagOption) ([]Tag, error)
GetSeriesTags returns the tags for a FRED series. Endpoint: GET /fred/series/tags?series_id={id}
func (*Client) GetSeriesUpdates ¶
func (c *Client) GetSeriesUpdates(ctx context.Context, opts ...UpdateOption) ([]SearchResult, error)
GetSeriesUpdates returns series that were recently updated. Endpoint: GET /fred/series/updates
func (*Client) GetSeriesVintageDates ¶
func (c *Client) GetSeriesVintageDates(ctx context.Context, seriesID string, opts ...ObservationOption) ([]time.Time, error)
GetSeriesVintageDates returns all vintage dates for a series. Endpoint: GET /fred/series/vintagedates?series_id={id}
func (*Client) GetSource ¶
GetSource returns information about a FRED data source. Endpoint: GET /fred/source?source_id={id}
func (*Client) GetSourceReleases ¶
func (c *Client) GetSourceReleases(ctx context.Context, id int, opts ...ReleaseListOption) ([]Release, error)
GetSourceReleases returns the releases for a FRED data source. Endpoint: GET /fred/source/releases?source_id={id}
func (*Client) GetSources ¶
GetSources returns all FRED data sources. Endpoint: GET /fred/sources
func (*Client) GetTagsSeries ¶
func (c *Client) GetTagsSeries(ctx context.Context, tagNames []string, opts ...SearchOption) ([]SearchResult, error)
GetTagsSeries returns series matching given tag names. Endpoint: GET /fred/tags/series?tag_names={tags}
func (*Client) SearchSeries ¶
func (c *Client) SearchSeries(ctx context.Context, text string, opts ...SearchOption) ([]SearchResult, error)
SearchSeries searches for series by keywords. Auto-paginates. Limit 0 = unlimited. Default limit = 1000. Endpoint: GET /fred/series/search?search_text={text}
Example ¶
client, _ := fred.New(fred.WithAPIKey("your-key"))
results, _ := client.SearchSeries(context.Background(), "GDP",
fred.WithLimit(5),
fred.WithSortOrder(fred.SortDesc),
)
for _, r := range results {
fmt.Printf("%s: %s\n", r.ID, r.Title)
}
func (*Client) SearchSeriesRelatedTags ¶
func (c *Client) SearchSeriesRelatedTags(ctx context.Context, text string, tagNames []string, opts ...TagOption) ([]Tag, error)
SearchSeriesRelatedTags searches for related tags by series search text and tag names. Endpoint: GET /fred/series/search/related_tags?series_search_text={text}&tag_names={tags}
type ClientOption ¶
ClientOption configures a Client.
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL sets a custom base URL (useful for testing).
func WithHTTPClient ¶
func WithHTTPClient(hc *http.Client) ClientOption
WithHTTPClient sets a custom HTTP client (useful for testing with httptest).
type MapData ¶
type MapData struct {
Title string `json:"title"`
Region string `json:"region"`
Seasonality string `json:"seasonality"`
Units string `json:"units"`
Frequency string `json:"frequency"`
Date string `json:"date"`
Data []MapDataEntry
}
MapData wraps GeoFRED series/regional data responses.
type MapDataEntry ¶
type MapDataEntry struct {
Region string `json:"region"`
Code string `json:"code"`
Value string `json:"value"`
SeriesID string `json:"series_id"`
}
MapDataEntry represents a single region's data point in GeoFRED.
func (*MapDataEntry) UnmarshalJSON ¶
func (m *MapDataEntry) UnmarshalJSON(data []byte) error
UnmarshalJSON handles both numeric and string value representations from FRED.
type MapDataOption ¶
type MapDataOption func(*mapDataParams)
MapDataOption configures GeoFRED series data calls.
func WithMapDate ¶
func WithMapDate(d string) MapDataOption
WithMapDate sets the date for map data (FRED: date).
func WithMapStartDate ¶
func WithMapStartDate(d string) MapDataOption
WithMapStartDate sets the start date for map data range (FRED: start_date).
type Observation ¶
type Observation struct {
Date time.Time
Value float64
RealtimeStart time.Time
RealtimeEnd time.Time
IsNA bool
}
Observation represents a single FRED data observation.
type ObservationOption ¶
type ObservationOption func(*obsParams)
ObservationOption configures a call to GetSeriesObservations or related vintage methods.
func WithAggregationMethod ¶
func WithAggregationMethod(m string) ObservationOption
WithAggregationMethod sets the frequency aggregation method (FRED: aggregation_method). Values: avg, sum, eop.
func WithFrequency ¶
func WithFrequency(f string) ObservationOption
WithFrequency sets the data frequency aggregation (FRED: frequency). Values: d, w, bw, m, q, sa, a, wef, weth, wew, wetu, wem, wesu, wesa, bwew, bwem.
func WithObservationEnd ¶
func WithObservationEnd(t time.Time) ObservationOption
WithObservationEnd sets the end of the observation period (FRED: observation_end).
func WithObservationLimit ¶
func WithObservationLimit(n int) ObservationOption
WithObservationLimit sets the maximum number of observations to return (FRED: limit).
func WithObservationOffset ¶
func WithObservationOffset(n int) ObservationOption
WithObservationOffset sets the offset for paginated observation requests (FRED: offset).
func WithObservationSortOrder ¶
func WithObservationSortOrder(o SortOrder) ObservationOption
WithObservationSortOrder sets the sort order for observations (FRED: sort_order).
func WithObservationStart ¶
func WithObservationStart(t time.Time) ObservationOption
WithObservationStart sets the start of the observation period (FRED: observation_start).
func WithOutputType ¶
func WithOutputType(t int) ObservationOption
WithOutputType sets the output type (FRED: output_type). Values: 1-4.
func WithRealtimeEnd ¶
func WithRealtimeEnd(t time.Time) ObservationOption
WithRealtimeEnd sets the end of the real-time period (FRED: realtime_end).
func WithRealtimeStart ¶
func WithRealtimeStart(t time.Time) ObservationOption
WithRealtimeStart sets the start of the real-time period (FRED: realtime_start).
func WithUnits ¶
func WithUnits(u string) ObservationOption
WithUnits sets the data value transformation (FRED: units). Values: lin, chg, ch1, pch, pc1, pca, cch, cca, log.
func WithVintageDates ¶
func WithVintageDates(dates ...string) ObservationOption
WithVintageDates sets vintage dates to request (FRED: vintage_dates).
type OrderBy ¶
type OrderBy string
OrderBy specifies the field to sort search results by.
const ( OrderBySearchRank OrderBy = "search_rank" OrderBySeriesID OrderBy = "series_id" OrderByTitle OrderBy = "title" OrderByUnits OrderBy = "units" OrderByFrequency OrderBy = "frequency" OrderBySeasonalAdjustment OrderBy = "seasonal_adjustment" OrderByRealtimeStart OrderBy = "realtime_start" OrderByRealtimeEnd OrderBy = "realtime_end" OrderByLastUpdated OrderBy = "last_updated" OrderByObservationStart OrderBy = "observation_start" OrderByObservationEnd OrderBy = "observation_end" OrderByPopularity OrderBy = "popularity" )
type RegionalDataOption ¶
type RegionalDataOption func(*regionalDataParams)
RegionalDataOption configures GeoFRED regional data calls.
func WithMapUnits ¶
func WithMapUnits(u string) RegionalDataOption
WithMapUnits sets the units for map data (FRED: units).
func WithRegionType ¶
func WithRegionType(t string) RegionalDataOption
WithRegionType sets the region type (FRED: region_type). Values: bea, msa, frb, necta, state, country, county, censusregion.
func WithRegionalDate ¶
func WithRegionalDate(d string) RegionalDataOption
WithRegionalDate sets the date for regional data (FRED: date).
func WithRegionalFrequency ¶
func WithRegionalFrequency(f string) RegionalDataOption
WithRegionalFrequency sets the frequency aggregation (FRED: frequency).
func WithSeason ¶
func WithSeason(s string) RegionalDataOption
WithSeason sets the seasonality adjustment (FRED: season). Values: SA, NSA, SSA, SAAR, NSAAR.
func WithSeriesGroup ¶
func WithSeriesGroup(g string) RegionalDataOption
WithSeriesGroup sets the series group ID (FRED: series_group). Required.
func WithTransformation ¶
func WithTransformation(t string) RegionalDataOption
WithTransformation sets the data transformation (FRED: transformation). Values: lin, chg, ch1, pch, pc1, pca, cch, cca, log.
type Release ¶
type Release struct {
ID int `json:"id"`
Name string `json:"name"`
PressRelease bool `json:"press_release"`
Link string `json:"link,omitempty"`
Notes string `json:"notes,omitempty"`
}
Release represents a FRED release.
type ReleaseDate ¶
type ReleaseDate struct {
ReleaseID int `json:"release_id"`
ReleaseName string `json:"release_name,omitempty"`
Date string `json:"date"`
}
ReleaseDate represents a release date entry.
type ReleaseDateOption ¶
type ReleaseDateOption func(*releaseDateParams)
ReleaseDateOption configures release date calls.
func WithIncludeNoData ¶
func WithIncludeNoData(b bool) ReleaseDateOption
WithIncludeNoData includes releases with no data (FRED: include_release_dates_with_no_data).
func WithReleaseDateLimit ¶
func WithReleaseDateLimit(n int) ReleaseDateOption
WithReleaseDateLimit sets the maximum number of release dates (FRED: limit).
func WithReleaseDateSortOrder ¶
func WithReleaseDateSortOrder(o SortOrder) ReleaseDateOption
WithReleaseDateSortOrder sets the sort order for release dates (FRED: sort_order).
type ReleaseListOption ¶
type ReleaseListOption func(*releaseListParams)
ReleaseListOption configures release listing calls.
func WithReleaseLimit ¶
func WithReleaseLimit(n int) ReleaseListOption
WithReleaseLimit sets the maximum number of releases to return (FRED: limit).
func WithReleaseSortOrder ¶
func WithReleaseSortOrder(o SortOrder) ReleaseListOption
WithReleaseSortOrder sets the sort order for release results (FRED: sort_order).
type ReleaseTableElement ¶
type ReleaseTableElement struct {
ElementID int `json:"element_id"`
ReleaseID int `json:"release_id"`
SeriesID string `json:"series_id,omitempty"`
ParentID int `json:"parent_id"`
Line string `json:"line"`
Type string `json:"type"`
Name string `json:"name"`
Level int `json:"-"` // computed from string
LevelRaw string `json:"level"`
Children []ReleaseTableElement `json:"children,omitempty"`
}
ReleaseTableElement represents an element in a release table.
type SearchOption ¶
type SearchOption func(*searchParams)
SearchOption configures a search or series-list call.
func WithExcludeTags ¶
func WithExcludeTags(tags ...string) SearchOption
WithExcludeTags excludes series matching the given tags (FRED: exclude_tag_names).
func WithFilter ¶
func WithFilter(variable, value string) SearchOption
WithFilter filters results by variable and value (FRED: filter_variable, filter_value).
func WithLimit ¶
func WithLimit(n int) SearchOption
WithLimit sets the maximum number of results to return. 0 means unlimited.
func WithOrderBy ¶
func WithOrderBy(ob OrderBy) SearchOption
WithOrderBy sets the field to sort search results by.
func WithSearchType ¶
func WithSearchType(t string) SearchOption
WithSearchType sets the search type (FRED: search_type). Values: full_text, series_id.
func WithSortOrder ¶
func WithSortOrder(o SortOrder) SearchOption
WithSortOrder sets the result sort order for search/series results.
func WithTagNames ¶
func WithTagNames(tags ...string) SearchOption
WithTagNames filters results to series matching the given tags (FRED: tag_names).
type SearchResult ¶
type SearchResult struct {
ID string `json:"id"`
RealtimeStart string `json:"realtime_start"`
RealtimeEnd string `json:"realtime_end"`
Title string `json:"title"`
ObservationStart string `json:"observation_start"`
ObservationEnd string `json:"observation_end"`
Frequency string `json:"frequency"`
FrequencyShort string `json:"frequency_short"`
Units string `json:"units"`
UnitsShort string `json:"units_short"`
SeasonalAdjustment string `json:"seasonal_adjustment"`
SeasonalAdjustmentShort string `json:"seasonal_adjustment_short"`
LastUpdated string `json:"last_updated"`
Popularity int `json:"popularity"`
Notes string `json:"notes,omitempty"`
}
SearchResult represents a series search result.
type Series ¶
type Series struct {
ID string `json:"id"`
RealtimeStart string `json:"realtime_start"`
RealtimeEnd string `json:"realtime_end"`
Title string `json:"title"`
ObservationStart string `json:"observation_start"`
ObservationEnd string `json:"observation_end"`
Frequency string `json:"frequency"`
FrequencyShort string `json:"frequency_short"`
Units string `json:"units"`
UnitsShort string `json:"units_short"`
SeasonalAdjustment string `json:"seasonal_adjustment"`
SeasonalAdjustmentShort string `json:"seasonal_adjustment_short"`
LastUpdated string `json:"last_updated"`
Popularity int `json:"popularity"`
Notes string `json:"notes,omitempty"`
Tags []Tag `json:"tags,omitempty"`
}
Series represents metadata for a FRED series.
type SeriesGroup ¶
type SeriesGroup struct {
Title string `json:"title"`
RegionType string `json:"region_type"`
SeriesGroup string `json:"series_group"`
Season string `json:"season"`
Units string `json:"units"`
Frequency string `json:"frequency"`
MinDate string `json:"min_date"`
MaxDate string `json:"max_date"`
}
SeriesGroup represents metadata for a GeoFRED map series.
type Source ¶
type Source struct {
ID int `json:"id"`
Name string `json:"name"`
Link string `json:"link,omitempty"`
Notes string `json:"notes,omitempty"`
}
Source represents a FRED data source.
type SourceOption ¶
type SourceOption func(*sourceParams)
SourceOption configures source calls.
func WithSourceLimit ¶
func WithSourceLimit(n int) SourceOption
WithSourceLimit sets the maximum number of sources (FRED: limit).
func WithSourceSortOrder ¶
func WithSourceSortOrder(o SortOrder) SourceOption
WithSourceSortOrder sets the sort order for source results (FRED: sort_order).
type TableOption ¶
type TableOption func(*tableParams)
TableOption configures release table calls.
func WithIncludeObservationValues ¶
func WithIncludeObservationValues(b bool) TableOption
WithIncludeObservationValues includes observation values in table rows (FRED: include_observation_values).
func WithObservationDate ¶
func WithObservationDate(d string) TableOption
WithObservationDate sets the observation date for table values (FRED: observation_date).
func WithTableElementID ¶
func WithTableElementID(id int) TableOption
WithTableElementID filters tables by element ID (FRED: element_id).
type Tag ¶
type Tag struct {
Name string `json:"name"`
GroupID string `json:"group_id"`
Notes string `json:"notes,omitempty"`
Created string `json:"created"`
Popularity int `json:"popularity"`
SeriesCount int `json:"series_count"`
}
Tag represents a FRED tag.
type TagOption ¶
type TagOption func(*tagParams)
TagOption configures a tag-related call.
func WithTagGroupID ¶
WithTagGroupID filters tags by group ID (FRED: tag_group_id).
func WithTagLimit ¶
WithTagLimit sets the maximum number of tags to return (FRED: limit).
func WithTagOrderBy ¶
WithTagOrderBy sets the field to sort tags by (FRED: order_by).
func WithTagSearchText ¶
WithTagSearchText filters tags by search text (FRED: search_text).
func WithTagSetExclude ¶
WithTagSetExclude excludes results by tag names (FRED: exclude_tag_names).
func WithTagSetNames ¶
WithTagSetNames filters results by tag names (FRED: tag_names).
func WithTagSortOrder ¶
WithTagSortOrder sets the sort order for tag results (FRED: sort_order).
type UpdateOption ¶
type UpdateOption func(*updateParams)
UpdateOption configures series updates calls.
func WithEndTime ¶
func WithEndTime(s string) UpdateOption
WithEndTime filters updates by end time (FRED: end_time).
func WithFilterValue ¶
func WithFilterValue(v string) UpdateOption
WithFilterValue filters updates by category (FRED: filter_value). Values: macro, regional, all.
func WithStartTime ¶
func WithStartTime(s string) UpdateOption
WithStartTime filters updates by start time (FRED: start_time).
func WithUpdateLimit ¶
func WithUpdateLimit(n int) UpdateOption
WithUpdateLimit sets the maximum number of updated series (FRED: limit).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
search
command
Example: search FRED for GDP-related series.
|
Example: search FRED for GDP-related series. |
|
series
command
Example: fetch and display recent 20-year Treasury yield observations.
|
Example: fetch and display recent 20-year Treasury yield observations. |
|
vintage
command
Example: get the first-published values for a series at each date.
|
Example: get the first-published values for a series at each date. |
