Package 'fredr'

Title: An R Client for the 'FRED' API
Description: An R client for the 'Federal Reserve Economic Data' ('FRED') API <https://research.stlouisfed.org/docs/api/>. Functions to retrieve economic time series and other data from 'FRED'.
Authors: Sam Boysel [aut, cre], Davis Vaughan [aut]
Maintainer: Sam Boysel <[email protected]>
License: MIT + file LICENSE
Version: 2.1.0.9000
Built: 2025-03-08 03:16:00 UTC
Source: https://github.com/sboysel/fredr

Help Index


Get a FRED category

Description

Get a FRED category

Usage

fredr_category(category_id)

Arguments

category_id

An integer ID for the category.

Value

A tibble object containing the name and parent ID for the category indicated by category_id.

API Documentation

fred/category

See Also

fredr_category_children(), fredr_category_related(), fredr_category_series(), fredr_category_tags(), fredr_category_related_tags()

Examples

if (fredr_has_key()) {
# Root category
fredr_category(category_id = 0L)
# "Production & Business Activity" category
fredr_category(category_id = 1L)
}

Get the child categories for a specified FRED parent category

Description

Get the child categories for a specified FRED parent category

Usage

fredr_category_children(
  category_id,
  ...,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

category_id

An integer ID for the category.

...

These dots only exist for future extensions and should be empty.

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object containing the name and ID for the children categories of the parent category indicated by category_id.

API Documentation

fred/category/children

See Also

fredr_category(), fredr_category_related(), fredr_category_series(), fredr_category_tags(), fredr_category_related_tags()

Examples

if (fredr_has_key()) {
# Children of the root category
fredr_category_children(category_id = 0L)
# Children of the "Production & Business Activity" category
fredr_category_children(category_id = 1L)
}

Get the series in a category

Description

Get the series in a category

Usage

fredr_category_series(
  category_id,
  ...,
  filter_variable = NULL,
  filter_value = NULL,
  tag_names = NULL,
  exclude_tag_names = NULL,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

category_id

An integer ID for the category.

...

These dots only exist for future extensions and should be empty.

filter_variable

A string indicating which attribute to indicate the attribute that results are filtered by. Possible values include: "frequency", "units", "seasonal_adjustment". No filtering by default.

filter_value

A string giving the value of the filter_variable attribute to filter results by. filter_variable must be set. No filtering by default.

tag_names

A string indicating which series tags to match. Multiple tags can be delimited by a semicolon in a single string (e.g. "usa;gnp").

exclude_tag_names

A string indicating which series tags should not be matched. Multiple tags can be delimited by a semicolon in a single string (e.g. '"usa;gnp"“).

limit

An positive integer indicating maximum number of results to return. Possible values are any integer between 1 and 1000 (default), inclusive.

offset

An non-negative integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

A string indicating an attribute by which the results are ordered by. Possible values include:

  • "series_id" (default)

  • "title"

  • "units"

  • "frequency"

  • "seasonal_adjustment"

  • "realtime_start"

  • "realtime_end"

  • "last_updated"

  • "observation_start"

  • "observation_end"

  • "popularity"

  • "group_popularity"

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object with information for series matching the request for the category specified in category_id.

API Documentation

fred/category/series

See Also

fredr_category(), fredr_category_children(), fredr_category_related(), fredr_category_tags(), fredr_category_related_tags()

Examples

if (fredr_has_key()) {
# Top 10 most popular series belonging to the "Employment Cost Index" category
fredr_category_series(category_id = 1L, limit = 10L, order_by = "popularity")
# Series in the "Employment Cost Index" category, ordered by descending observation frequency
fredr_category_series(category_id = 4L, order_by = "frequency", sort_order = "desc")
}

Get the FRED tags for a category

Description

Get the FRED tags for a category. Optionally, filter results by tag name, tag group, or search. Series are assigned tags and categories. Alternatively, it is possible to get the tags for a category through a call to a function in the fredr/series endpoint. See fredr_series. No tags exist for a category that does not have series.

Usage

fredr_category_tags(
  category_id,
  ...,
  tag_names = NULL,
  tag_group_id = NULL,
  search_text = NULL,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

category_id

An integer ID for the category.

...

These dots only exist for future extensions and should be empty.

tag_names

A string indicating which series tags to match. Multiple tags can be delimited by a semicolon in a single string (e.g. "usa;gnp").

tag_group_id

A string representing the tag group id to filter tags by type. No filtering by default. Possible values include:

  • "freq" - Frequency

  • "gen" - General or Concept

  • "geo" - Geography

  • "geot" - Geography Type

  • "rls" - Release

  • "seas" - Seasonal Adjustment

  • "src" - Source

search_text

A string to match text of tags. No matching by default.

limit

An positive integer indicating maximum number of results to return. Possible values are any integer between 1 and 1000 (default), inclusive.

offset

An non-negative integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

Order results by values of the specified attribute. Possible values include: "series_count" (default), ⁠"popularity"``, ⁠"created"⁠, ⁠"name"⁠, ⁠"group_id"'.

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object information on tags matching the request and their descriptions. Data include tag name, group ID, popularity, series count, tag creation date, and additional notes.

API Documentation

fred/category/tags

See Also

fredr_category(), fredr_category_children(), fredr_category_related(), fredr_category_series(), fredr_category_related_tags()

Examples

if (fredr_has_key()) {
# Tags assigned to series in the "Production & Business Activity" category
fredr_category_tags(category = 1L)
# Select the "nation" and "monthly" tags in the "Production & Business Activity" category
fredr_category_tags(category = 3L, tag_names = "nation;monthly", order_by = "popularity")
}

Open the web documentation for a certain FRED API topic.

Description

Opens FRED API web documentation in a new web browser tab.

Usage

fredr_docs()

API Documentation

FRED API

Examples

if (interactive()) {
fredr_docs()
}

List of available FRED API endpoints.

Description

List of available FRED API endpoints.

Usage

fredr_endpoints

Format

A tibble with 31 rows and 3 variables:

endpoint

endpoint name (e.g. "fred/category", "fredr/series/observations", "fredr/tags"). This name can be supplied to the endpoint parameter in fredr_docs() to open the FRED API endpoint documentation in a web browser.

type

endpoint type (e.g. "Categories", "Releases", "Series", "Sources", and "Tags".)

note

endpoint details

API Documentation

FRED API

See Also

fredr_request(), fredr_docs()


Get a release of economic data

Description

Get a release of economic data

Usage

fredr_release(release_id, ..., realtime_start = NULL, realtime_end = NULL)

Arguments

release_id

An integer ID of the release.

...

These dots only exist for future extensions and should be empty.

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/release

See Also

fredr_releases(), fredr_releases_dates(), fredr_release_dates(), fredr_release_series(), fredr_release_sources(), fredr_release_tags(), fredr_release_related_tags(), fredr_release_tables()

Examples

if (fredr_has_key()) {
# Release as of today
fredr_release(release_id = 20)

# For some releases, adding realtime dates returns the history of changes
# the release went through
fredr_release(9, realtime_start = as.Date("1950-01-01"))
}

Get release dates for a single release of economic data

Description

Get release dates for a single release of economic data

Usage

fredr_release_dates(
  release_id,
  ...,
  limit = NULL,
  offset = NULL,
  sort_order = NULL,
  include_release_dates_with_no_data = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

release_id

An integer ID of the release.

...

These dots only exist for future extensions and should be empty.

limit

An integer limit on the maximum number of results to return. Defaults to 10000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

sort_order

A string representing the order of the resulting release dates. Possible values are: "asc" (default), and "desc".

include_release_dates_with_no_data

A boolean value indicating if the results with no data available should be returned as well. Default is FALSE.

realtime_start

A Date indicating the start of the real-time period. Defaults to 1776-07-04 (earliest available). For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to 9999-12-31 (latest available). For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/release/dates

See Also

fredr_releases(), fredr_releases_dates(), fredr_release(), fredr_release_series(), fredr_release_sources(), fredr_release_tags(), fredr_release_related_tags(), fredr_release_tables()

Examples

if (fredr_has_key()) {
fredr_release_dates(release_id = 20L)

# Call the function with an "as of" Date of 1997-03-14
fredr_release_dates(release_id = 20L, realtime_end = as.Date("1997-03-14"))
}

Get the series on a release of economic data

Description

Get the series on a release of economic data

Usage

fredr_release_series(
  release_id,
  ...,
  filter_variable = NULL,
  filter_value = NULL,
  tag_names = NULL,
  exclude_tag_names = NULL,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

release_id

An integer ID of the release.

...

These dots only exist for future extensions and should be empty.

filter_variable

A string indicating which attribute to indicate the attribute that results are filtered by. Possible values include: "frequency", "units", "seasonal_adjustment". No filtering by default.

filter_value

A string giving the value of the filter_variable attribute to filter results by. filter_variable must be set. No filtering by default.

tag_names

A string indicating which series tags to match. Multiple tags can be delimited by a semicolon in a single string (e.g. '"usa;gnp"“).

exclude_tag_names

A string indicating which series tags should not be matched. Multiple tags can be delimited by a semicolon in a single string (e.g. '"usa;gnp"“).

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

A string indicating an attribute by which the results are ordered by. Possible values include:

  • "series_id" (default)

  • "title"

  • "units"

  • "frequency"

  • "seasonal_adjustment"

  • "realtime_start"

  • "realtime_end"

  • "last_updated"

  • "observation_start"

  • "observation_end"

  • "popularity"

  • "group_popularity"

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/release/series

See Also

fredr_releases(), fredr_releases_dates(), fredr_release(), fredr_release_dates(), fredr_release_sources(), fredr_release_tags(), fredr_release_related_tags(), fredr_release_tables()

Examples

if (fredr_has_key()) {
fredr_release_series(release_id = 20L)

fredr_release_series(release_id = 20L, order_by = "popularity")

# Extract the "catalog" of series from a release on a certain date
fredr_release_series(
   release_id = 20L,
   realtime_end = as.Date("2018-07-13"),
   order_by = "popularity"
)
}

Get the sources for a release of economic data

Description

Get the sources for a release of economic data

Usage

fredr_release_sources(
  release_id,
  ...,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

release_id

An integer ID of the release.

...

These dots only exist for future extensions and should be empty.

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/release/sources

See Also

fredr_releases(), fredr_releases_dates(), fredr_release(), fredr_release_dates(), fredr_release_series(), fredr_release_tags(), fredr_release_related_tags(), fredr_release_tables()

Examples

if (fredr_has_key()) {
# Where does the data for ID 10 come from?
fredr_release_sources(release_id = 10L)
}

Get release table trees for a given release

Description

You can go directly to the tree structure by passing the appropriate element_id. You may also use a drill-down approach to start at the root (top most) element by leaving the element_id off.

Usage

fredr_release_tables(
  release_id,
  ...,
  element_id = NULL,
  include_observation_values = NULL,
  observation_date = NULL
)

Arguments

release_id

An integer ID of the release.

...

These dots only exist for future extensions and should be empty.

element_id

An integer ID for the desired release table element.

include_observation_values

A boolean indicating if observations should be returned with the release table element. Observations will only be returned for a series type element. Default is FALSE.

observation_date

A Date indicating which observation date to include with the release table. Default is 9999-12-31 (latest date available).

Value

A tibble object with nested results.

API Documentation

fred/release/tables

See Also

fredr_releases(), fredr_release_dates(), fredr_releases_dates(), fredr_release(), fredr_release_series(), fredr_release_sources(), fredr_release_tags(), fredr_release_related_tags()

Examples

if (fredr_has_key()) {
fredr_release_tables(release_id = 10L)

# Digging further into a release element
fredr_release_tables(release_id = 53L, element_id = 12886)
}

Get the FRED tags for a release

Description

Get the FRED tags for a release. Optionally, filter results by tag name, tag group, or search text.

Usage

fredr_release_tags(
  release_id,
  ...,
  tag_names = NULL,
  tag_group_id = NULL,
  search_text = NULL,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

release_id

An integer ID of the release.

...

These dots only exist for future extensions and should be empty.

tag_names

A semicolon delimited string of tag names to only include in the response. No filtering by tag names by default (i.e. all FRED tags returned).

tag_group_id

A string tag group id to filter tags by type. No filtering by tag group by default. Possible values are:

  • "freq" = Frequency

  • "gen" = General or Concept

  • "geo" = Geography

  • "geot" = Geography Type

  • "rls" = Release

  • "seas" = Seasonal Adjustment

  • "src" = Source

search_text

A string indicating the words to find matching tags with. No filtering by search words by default.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

Order results by values of the specified attribute. Possible values are:

  • "series_count" (default)

  • "popularity"

  • "created"

  • "name"

  • "group_id"

sort_order

A string representing the order of the resulting series, sorted by the attribute values specified by order_by. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/release/tags

See Also

fredr_releases(), fredr_releases_dates(), fredr_release(), fredr_release_dates(), fredr_release_series(), fredr_release_sources(), fredr_release_related_tags(), fredr_release_tables()

Examples

if (fredr_has_key()) {
fredr_release_tags(release_id = 10L)
}

Get all releases of economic data

Description

Get all releases of economic data

Usage

fredr_releases(
  ...,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

...

These dots only exist for future extensions and should be empty.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

Order results by values of the specified attribute. Possible values include: 'release_id' (default), 'name', 'press_release', 'realtime_start', 'realtime_end'.

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/releases

See Also

fredr_releases_dates(), fredr_release(), fredr_release_dates(), fredr_release_series(), fredr_release_sources(), fredr_release_tags(), fredr_release_related_tags(), fredr_release_tables(),

Examples

if (fredr_has_key()) {
fredr_releases(limit = 20L)
}

Get release dates for all releases of economic data.

Description

Get release dates for all releases of economic data. Note that release dates are published by data sources and do not necessarily represent when data will be available on the FRED or ALFRED websites.

Usage

fredr_releases_dates(
  ...,
  limit = NULL,
  offset = NULL,
  sort_order = NULL,
  order_by = NULL,
  include_release_dates_with_no_data = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

...

These dots only exist for future extensions and should be empty.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

sort_order

A string representing the order of the resulting series. Possible values are: "asc" and "desc" (default).

order_by

Order results by values of the specified attribute. Possible values include: 'release_date' (default), 'release_id', 'release_name'.

include_release_dates_with_no_data

A boolean value indicating if the results with no data available should be returned as well. Default is FALSE.

realtime_start

A Date indicating the start of the real-time period. Defaults to the first day of the current year. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to 9999-12-31 (latest available). For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/releases/dates

See Also

fredr_releases(), fredr_release_dates(), fredr_release(), fredr_release_series(), fredr_release_sources(), fredr_release_tags(), fredr_release_related_tags(), fredr_release_tables()

Examples

if (fredr_has_key()) {
fredr_releases_dates(limit = 20L)
}

Send a request to the FRED API

Description

Send a general request to the FRED API by specifying an endpoint and a sequence of parameters. The fredr_request() function forms and submits a request to a specified endpoint of the FRED API. The result is either the response object from httr::GET() or the response parsed as a tibble.

Usage

fredr_request(
  endpoint,
  ...,
  to_frame = TRUE,
  print_req = FALSE,
  retry_times = 3L
)

Arguments

endpoint

A string representing the FRED API endpoint of interest. See fredr_endpoints for a list of endpoint possible values. Required parameter.

...

A series of named parameters to be used in the query. Must be of the form param_key = "param_value". Acceptable parameters are endpoint-specific. See the fredr_endpoints data frame for a list of endpoints and fredr_docs() to access the web documentation for each endpoint function.

to_frame

A boolean value indicating whether or not the response should be parsed and formatted as a data frame. If FALSE, a response object is returned and further processing can be done with httr::content(). Default is TRUE.

print_req

A boolean value indicating whether or not the request should be printed as well. Useful for debugging. Default is FALSE.

retry_times

An integer indicating the maximum number of requests to attempt. Passed directly to httr::RETRY(). Default is 3.

Value

If to_frame = TRUE, a tibble containing the parsed response. If to_frame = FALSE, a response object returned directly from httr::GET().

API Documentation

FRED API

Examples

if (fredr_has_key()) {
fredr_request(
  endpoint = "series/observations",
  series_id = "GNPCA",
  observation_start = "1990-01-01",
  observation_end = "2000-01-01"
)

# Compare to to_frame = `FALSE`
resp <- fredr_request(
  endpoint = "series/observations",
  series_id = "GNPCA",
  observation_start = "1990-01-01",
  observation_end = "2000-01-01",
  to_frame = FALSE
)
}

Return basic information for a FRED series.

Description

Given a series ID, return basic information for a FRED series. Note that this function will not return the actual series data. For this functionality, see fredr_series_observations().

Usage

fredr_series(series_id, ..., realtime_start = NULL, realtime_end = NULL)

Arguments

series_id

A string ID for the FRED series.

...

These dots only exist for future extensions and should be empty.

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object (1 row) with information for the series specified by series_id.

API Documentation

fred/series

See Also

fredr_series_observations(), fredr_series_search_text(), fredr_series_search_id(), fredr_series_search_tags(), fredr_series_search_related_tags(), fredr_series_categories(), fredr_series_release(), fredr_series_tags(), fredr_series_updates(), fredr_series_vintagedates().

Examples

if (fredr_has_key()) {
# Return information for the "UNRATE" series
fredr_series(series_id = "UNRATE")
}

Get the categories for a FRED series

Description

Given a series ID, return information on the categories to which a series belongs as a tibble object.

Usage

fredr_series_categories(
  series_id,
  ...,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

series_id

A string ID for the FRED series.

...

These dots only exist for future extensions and should be empty.

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object with information on the categories to which the series specified by series_id belongs. Data include category ID, name, parent category ID, and notes.

API Documentation

fred/series/categories

See Also

fredr_series_observations(), fredr_series_search_text(), fredr_series_search_id(), fredr_series_search_tags(), fredr_series_search_related_tags(), fredr_series(), fredr_series_release(), fredr_series_tags(), fredr_series_updates(), fredr_series_vintagedates().

Examples

if (fredr_has_key()) {
# Return the categories to which the "UNRATE" series belongs
fredr_series_categories(series_id = "UNRATE")
}

Get observations of a FRED series

Description

Given a series ID, return observations of that series as a tibble object. fredr() is an alias for fredr_series_observations().

Usage

fredr_series_observations(
  series_id,
  ...,
  observation_start = NULL,
  observation_end = NULL,
  frequency = NULL,
  aggregation_method = NULL,
  limit = NULL,
  offset = NULL,
  sort_order = NULL,
  units = NULL,
  realtime_start = NULL,
  realtime_end = NULL,
  vintage_dates = NULL,
  output_type = NULL
)

fredr(
  series_id,
  ...,
  observation_start = NULL,
  observation_end = NULL,
  frequency = NULL,
  aggregation_method = NULL,
  limit = NULL,
  offset = NULL,
  sort_order = NULL,
  units = NULL,
  realtime_start = NULL,
  realtime_end = NULL,
  vintage_dates = NULL,
  output_type = NULL
)

Arguments

series_id

A string ID for the FRED series.

...

These dots only exist for future extensions and should be empty.

observation_start

A Date indicating the start of the observation period. Defaults to 1776-07-04, the earliest available date.

observation_end

A Date indicating the end of the observation period. Defaults to 9999-12-31, the latest available date.

frequency

A string representing a lower frequency to aggregate to. Defaults to no frequency aggregation. Possible values are:

  • "d" - Daily

  • "w" - Weekly

  • "bw" - Biweekly

  • "m" - Monthly

  • "q" - Quarterly

  • "sa" - Semiannual

  • "a" - Annual

  • "wem" - Weekly, ending Monday

  • "wetu" - Weekly, ending Tuesday

  • "wew" - Weekly, ending Wednesday

  • "weth" - Weekly, ending Thursday

  • "wef" - Weekly, ending Friday

  • "wesa" - Weekly, ending Saturday

  • "wesu" - Weekly, ending Sunday

  • "bwew" - Biweekly, ending Wednesday

  • "bwem" - Biweekly, ending Monday

aggregation_method

A string representing the aggregation method used for frequency aggregation. This parameter has no affect is frequency is not set. Possible values are:

  • "avg" for average

  • "sum" for sum

  • "eop" for end of period value

limit

An integer limit on the maximum number of results to return. Defaults to 100000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

units

A string indicating the data value transformation. Defaults to "lin". Possible values are:

  • "lin" - Levels (No transformation)

  • "chg" - Change

  • "ch1" - Change from 1 year ago

  • "pch" - Percent change

  • "pc1" - Percent change from 1 year ago

  • "pca" - Compounded annual rate of change

  • "cch" - Continuously compounded rate of change

  • "cca" - Continuously compounded annual rate of change

  • "log" - Natural log

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

vintage_dates

A vector of Date objects to download data for. Vintage dates are used to download data as it existed on these specified dates in history. They can be specified instead of a real-time period using realtime_start and realtime_end. Defaults to no vintage dates.

output_type

An integer indicating the output type. Not used unless realtime_start is used. Possible values are:

  • 1 for Observations by Real-Time Period (default)

  • 2 for Observations by Vintage Date, All Observations

  • 3 for Observations by Vintage Date, New and Revised Observations Only

  • 4 for Observations, Initial Release Only.

Value

A tibble object with observation dates and values.

API Documentation

fred/series/observations

See Also

fredr_series_search_text(), fredr_series_search_id(), fredr_series_search_tags(), fredr_series_search_related_tags(), fredr_series(), fredr_series_categories(), fredr_series_release(), fredr_series_tags(), fredr_series_updates(), fredr_series_vintagedates().

Examples

if (fredr_has_key()) {
# Observations for "UNRATE" series between 1980 and 2000.  Units are in terms
# of change from previous observation.
fredr(
  series_id = "UNRATE",
  observation_start = as.Date("1980-01-01"),
  observation_end = as.Date("2000-01-01"),
  units = "chg"
)
# All observations for "OILPRICE" series.  The data is first aggregated by
# quarter by taking the average of all observations in the quarter then
# transformed by taking the natural logarithm.
fredr(
  series_id = "OILPRICE",
  frequency = "q",
  aggregation_method = "avg",
  units = "log"
)

# To retrieve values for multiple series, use purrr's map_dfr() function.

if (requireNamespace("purrr", quietly = TRUE)) {

  library(purrr)
  purrr::map_dfr(c("UNRATE", "OILPRICE"), fredr)

  # Using purrr::pmap_dfr() allows you to use varying optional parameters
  params <- list(
    series_id = c("UNRATE", "OILPRICE"),
    frequency = c("m", "q")
  )

  purrr::pmap_dfr(
    .l = params,
    .f = ~ fredr(series_id = .x, frequency = .y)
  )

}

}

Get the release for a FRED series

Description

Given a series ID, return information on a series as a tibble object.

Usage

fredr_series_release(
  series_id,
  ...,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

series_id

A string ID for the FRED series.

...

These dots only exist for future extensions and should be empty.

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object with information on the release for the series specified by the series_id parameter. Data include release ID, real-time periods, release name, and links to press releases, if available.

API Documentation

fred/series/release

See Also

fredr_series_observations(), fredr_series_search_text(), fredr_series_search_id(), fredr_series_search_tags(), fredr_series_search_related_tags(), fredr_series(), fredr_series_categories(), fredr_series_tags(), fredr_series_updates(), fredr_series_vintagedates().

Examples

if (fredr_has_key()) {
# Get release information for the "UNRATE" series
fredr_series_release(series_id = "UNRATE")
}

Get the FRED tags for a series search.

Description

Return the FRED tags by searching for matches in series text.

Usage

fredr_series_search_tags(
  series_search_text,
  ...,
  tag_names = NULL,
  tag_group_id = NULL,
  tag_search_text = NULL,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

series_search_text

A string containing the series search text.

...

These dots only exist for future extensions and should be empty.

tag_names

A semicolon delimited string of tag names to return. Defaults no filtering by tag names.

tag_group_id

A string indicating the tag group id to filter tags by type. Defaults to no filtering by tag group. Possible values are

  • "freq" = Frequency

  • "gen" = General or Concept

  • "geo" = Geography

  • "geot" = Geography Type

  • "rls" = Release

  • "seas" = Seasonal Adjustment

  • "src" = Source

tag_search_text

A string to match tag names. Defaults to no filtering by tag name matching.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

A string indicating the attribute to order results by. Defaults to "series_count". Possible values are:

  • "series_count"

  • "popularity"

  • "created"

  • "name"

  • "group_id"

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object where each row represents a series tag matching the query. Data include the tag name, group ID, tag creation date, popularity, series count, and additional notes.

References

API Documentation:

series/search/tags

See Also

fredr_series_search_text(), fredr_series_search_id(), fredr_series_search_related_tags(), fredr_tags()

Examples

if (fredr_has_key()) {
# Search for tags matching the series text "gnp"
fredr_series_search_tags("gnp")
# Search for tags matching the series text "oil" and the tag text "usa"
fredr_series_search_tags(
  series_search_text = "oil",
  tag_search_text = "usa"
)
# Search for tags matching the series text "oil" and the tag text "usa".
# Return only results in the "geo" (Geography) group
fredr_series_search_tags(
  series_search_text = "oil",
  tag_group_id = "geo",
  tag_search_text = "usa"
)
}

Get the tags for a FRED series

Description

Given a series ID, return associated tags for the series as a tibble object.

Usage

fredr_series_tags(
  series_id,
  ...,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

series_id

A string ID for the FRED series.

...

These dots only exist for future extensions and should be empty.

order_by

A string indicating the attribute by which to order the Possible values include "series_count" (default), "popularity", "created", "name", and "group_id".

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A ⁠tibble`` object where each row is represents a tag associated with the series specified by ⁠series_id'. Data include tag name, group ID, popularity, series count, tag creation date, and additional notes.

API Documentation

fred/series/tags

See Also

fredr_series_observations(), fredr_series_search_text(), fredr_series_search_id(), fredr_series_search_tags(), fredr_series_search_related_tags(), fredr_series(), fredr_series_categories(), fredr_series_release(), fredr_series_updates(), fredr_series_vintagedates().

Examples

if (fredr_has_key()) {
# Return all tags assigned to the "UNRATE" series and order the results by
# group ID.
fredr_series_tags(series_id = "UNRATE", order_by = "group_id")
}

Get a set of recently updated FRED series

Description

Returns information on the recently updated series on the FRED server.

Usage

fredr_series_updates(
  ...,
  filter_value = NULL,
  start_time = NULL,
  end_time = NULL,
  limit = NULL,
  offset = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

...

These dots only exist for future extensions and should be empty.

filter_value

Filter results by type of geographic region of economic the data series. Possible values include

  • "all" (default) - no filtering

  • "macro" - filters results macroeconomic regions (e.g. entire countries)

  • "regional" - filters results to series for regions of the United States such as states, counties, and Metropolitan Statistical Areas (MSA).

start_time

A datetime object indicating the start time to filter series updates results.

end_time

A datetime object indicating the start time to filter series updates results.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object where each row represents a series. Rows are sorted with most recently updated series appearing first.

API Documentation

fred/series/updates

See Also

fredr_series_observations(), fredr_series_search_text(), fredr_series_search_id(), fredr_series_search_tags(), fredr_series_search_related_tags(), fredr_series(), fredr_series_release(), fredr_series_tags(), fredr_series_categories(), fredr_series_vintagedates().

Examples

if (fredr_has_key()) {
# Get all recently updated "regional" series
fredr_series_updates(filter_value = "regional")
# Most recently udpated series are returned first
updates <- fredr_series_updates(filter_value = "regional")$last_updated
is.unsorted(rev(as.POSIXct(updates)))
}

Get the data vintage dates for a FRED series

Description

Given a series ID, return a sequence of dates in history when a series' data values were revised or new data values were released as a tibble object.

Usage

fredr_series_vintagedates(
  series_id,
  ...,
  limit = NULL,
  offset = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

series_id

A string ID for the FRED series.

...

These dots only exist for future extensions and should be empty.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object where each row is a distinct vintage date.

API Documentation

fred/series/vintagedates

See Also

fredr_series_observations(), fredr_series_search_text(), fredr_series_search_id(), fredr_series_search_tags(), fredr_series_search_related_tags(), fredr_series(), fredr_series_release(), fredr_series_tags(), fredr_series_categories(), fredr_series_updates().

Examples

if (fredr_has_key()) {
# All data vintages for the "UNRATE" series
fredr_series_vintagedates(series_id = "UNRATE")
# 10 most recent data vintages for the "UNRATE" series
fredr_series_vintagedates(series_id = "UNRATE", limit = 10L, sort_order = "desc")
}

Get a source of economic data

Description

Get a source of economic data

Usage

fredr_source(source_id, ..., realtime_start = NULL, realtime_end = NULL)

Arguments

source_id

An integer ID for the data source.

...

These dots only exist for future extensions and should be empty.

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/source

See Also

fredr_sources(), fredr_source_releases()

Examples

if (fredr_has_key()) {
fredr_source(source_id = 14L)

# Has this source ID ever changed over time?
fredr_source(source_id = 14L, realtime_start = as.Date("1990-01-01"))
}

Get the releases for a source

Description

Get the releases for a source

Usage

fredr_source_releases(
  source_id,
  ...,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

source_id

An integer ID for the data source.

...

These dots only exist for future extensions and should be empty.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

A string indicating which attribute should be used to order the results. Possible values:

  • "release_id" (default)

  • "name"

  • "press_release"

  • "realtime_start"

  • "realtime_end"

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/source/releases

See Also

fredr_sources(), fredr_source()

Examples

if (fredr_has_key()) {
# Board of Governors
fredr_source_releases(source_id = 1L)

# University of Michigan
fredr_source_releases(source_id = 14L, realtime_start = as.Date("1950-01-01"))
}

Get all sources of economic data

Description

Get all sources of economic data

Usage

fredr_sources(
  ...,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

...

These dots only exist for future extensions and should be empty.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

A string indicating which attribute should be used to order the results. Possible values: "source_id" (default), "name", "realtime_start", "realtime_end".

sort_order

A string representing the order of the resulting series. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object.

API Documentation

fred/sources

See Also

fredr_source(), fredr_source_releases()

Examples

if (fredr_has_key()) {
fredr_sources(limit = 20L)
}

Get FRED series tags

Description

Get FRED tags. Optionally, filter results by tag name, tag group, or search text. FRED tags are attributes assigned to a series. By default, all tags are returned, unfiltered, up to the limit.

Usage

fredr_tags(
  ...,
  tag_names = NULL,
  tag_group_id = NULL,
  search_text = NULL,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

...

These dots only exist for future extensions and should be empty.

tag_names

A semicolon delimited string of tag names to only include in the response. No filtering by tag names by default (i.e. all FRED tags returned).

tag_group_id

A string tag group id to filter tags by type. No filtering by tag group by default. Possible values are:

  • "freq" = Frequency

  • "gen" = General or Concept

  • "geo" = Geography

  • "geot" = Geography Type

  • "rls" = Release

  • "seas" = Seasonal Adjustment

  • "src" = Source

search_text

A string indicating the words to find matching tags with. No filtering by search words by default.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

Order results by values of the specified attribute. Possible values are:

  • "series_count" (default)

  • "popularity"

  • "created"

  • "name"

  • "group_id"

sort_order

A string representing the order of the resulting series, sorted by the attribute values specified by order_by. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble containing tags and their descriptions. Data include tag name, group ID, popularity, series count, tag creation date, and additional notes.

API Documentation

fred/tags

See Also

fredr_category_tags(), fredr_category_related_tags(), fredr_docs(), fredr_release_tags(), fredr_release_related_tags(), fredr_series_search_tags(), fredr_series_search_related_tags(), fredr_tags_series(), fredr_related_tags()

Examples

if (fredr_has_key() && interactive()) {
# Information for all tags
fredr_tags()

# Information for just the "gdp" and "oecd" tags
fredr_tags(tag_names = "gdp;oecd")

# Information for all tags in the "geo" group
fredr_tags(tag_group_id = "geo")

# Information for tags matching the text "unemployment"
fredr_tags(search_text = "unemployment")
}

Find FRED series matching tag names

Description

Get the series matching tags in the tag_names parameter. Exclude tags in the exclude_tag_names parameter.

Usage

fredr_tags_series(
  tag_names,
  ...,
  exclude_tag_names = NULL,
  limit = NULL,
  offset = NULL,
  order_by = NULL,
  sort_order = NULL,
  realtime_start = NULL,
  realtime_end = NULL
)

Arguments

tag_names

A semicolon delimited string of tag names to find series using.

...

These dots only exist for future extensions and should be empty.

exclude_tag_names

A semicolon delimited string of tag names that series match none of. No exclusions are done by default.

limit

An integer limit on the maximum number of results to return. Defaults to 1000, the maximum.

offset

An integer used in conjunction with limit for long series. This mimics the idea of pagination to retrieve large amounts of data over multiple calls. Defaults to 0.

order_by

A string indicating which attribute by which to order the results of the query. Possible values include:

  • "series_id" (default)

  • "title"

  • "units"

  • "frequency"

  • "seasonal_adjustment"

  • "realtime_start"

  • "realtime_end"

  • "last_updated"

  • "observation_start"

  • "observation_end"

  • "popularity"

  • "group_popularity"

sort_order

A string representing the order of the resulting series, sorted by the attribute values specified by order_by. Possible values are: "asc" (default), and "desc".

realtime_start

A Date indicating the start of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

realtime_end

A Date indicating the end of the real-time period. Defaults to today's date. For more information, see Real-Time Periods.

Value

A tibble object containing FRED series with tags matching tag_names and their descriptions.

API Documentation

fred/tags/series

See Also

fredr_category_tags(), fredr_category_related_tags(), fredr_docs(), fredr_release_tags(), fredr_release_related_tags(), fredr_series_search_tags(), fredr_series_search_related_tags(), fredr_tags(), fredr_related_tags()

Examples

if (fredr_has_key()) {
# All series tagged with "gdp"
fredr_tags_series(tag_names = "gdp")
# All series tagged with "gdp" and not tagged with "quarterly"
fredr_tags_series(
   tag_names = "gdp",
   exclude_tag_names = "quarterly"
 )
# Top 100 most popular non-quarterly series matching GDP
fredr_tags_series(
   tag_names = "gdp",
   exclude_tag_names = "quarterly",
   order_by = "popularity",
   limit = 100L
)
}

FRED API key

Description

Users of fredr must authenticate with the FRED API by use of an API key. This key should be stored as an environment variable, FRED_API_KEY.

  • fredr_get_key() will retrieve the key, if set, or it will return NULL if the key is unset.

  • fredr_set_key() will set the key for the current R session. For persistence across sessions, set the environment variable. See the Details section for more information.

  • fredr_has_key() returns TRUE if a key can be found. Otherwise it returns FALSE.

Usage

fredr_set_key(key)

fredr_get_key()

fredr_has_key()

Arguments

key

A valid FRED API key as a string. Obtain one at the API Keys page. Can also be NULL to unset the key for the current R session.

Details

The preferred method to set the key is to set the FRED_API_KEY environment variable in an .Renviron file. The easiest way to do this is by calling usethis::edit_r_environ(). Don't forget to restart R after setting the key.

References

See St. Louis Fed Web Services API Keys to obtain an API key.

See Also

Note that by using a FRED API key, you agree to the FRED API Terms of Use.

Examples

original_key <- fredr_get_key()

# Set a once per session key
fredr_set_key("foo")

# Get it
fredr_get_key()

# Reset to original key
fredr_set_key(original_key)