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 |
Get a FRED category
fredr_category(category_id)
fredr_category(category_id)
category_id |
An integer ID for the category. |
A tibble
object containing the name and parent ID for the category
indicated by category_id
.
fredr_category_children()
, fredr_category_related()
,
fredr_category_series()
, fredr_category_tags()
, fredr_category_related_tags()
if (fredr_has_key()) { # Root category fredr_category(category_id = 0L) # "Production & Business Activity" category fredr_category(category_id = 1L) }
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
fredr_category_children( category_id, ..., realtime_start = NULL, realtime_end = NULL )
fredr_category_children( category_id, ..., realtime_start = NULL, realtime_end = NULL )
category_id |
An integer ID for the category. |
... |
These dots only exist for future extensions and should be empty. |
realtime_start |
A |
realtime_end |
A |
A tibble
object containing the name and ID for the children
categories of the parent category indicated by category_id
.
fredr_category()
, fredr_category_related()
,
fredr_category_series()
, fredr_category_tags()
,
fredr_category_related_tags()
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) }
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
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 )
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 )
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: |
filter_value |
A string giving the value of the |
tag_names |
A string indicating which series tags to match. Multiple
tags can be delimited by a semicolon in a single string (e.g. |
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 |
offset |
An non-negative integer used in conjunction with |
order_by |
A string indicating an attribute by which the results are ordered by. Possible values include:
|
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
A tibble
object with information for series matching the request for
the category specified in category_id
.
fredr_category()
, fredr_category_children()
, fredr_category_related()
,
fredr_category_tags()
, fredr_category_related_tags()
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") }
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. 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.
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 )
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 )
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. |
tag_group_id |
A string representing the tag group id to filter tags by type. No filtering by default. Possible values include:
|
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 |
offset |
An non-negative integer used in conjunction with |
order_by |
Order results by values of the specified attribute.
Possible values include: |
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
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.
fredr_category()
, fredr_category_children()
, fredr_category_related()
,
fredr_category_series()
, fredr_category_related_tags()
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") }
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") }
Opens FRED API web documentation in a new web browser tab.
fredr_docs()
fredr_docs()
if (interactive()) { fredr_docs() }
if (interactive()) { fredr_docs() }
List of available FRED API endpoints.
fredr_endpoints
fredr_endpoints
A tibble
with 31 rows and 3 variables:
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.
endpoint type (e.g. "Categories", "Releases", "Series", "Sources", and "Tags".)
endpoint details
Get a release of economic data
fredr_release(release_id, ..., realtime_start = NULL, realtime_end = NULL)
fredr_release(release_id, ..., realtime_start = NULL, realtime_end = NULL)
release_id |
An integer ID of the release. |
... |
These dots only exist for future extensions and should be empty. |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_releases()
, fredr_releases_dates()
, fredr_release_dates()
,
fredr_release_series()
, fredr_release_sources()
, fredr_release_tags()
,
fredr_release_related_tags()
, fredr_release_tables()
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")) }
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
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 )
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 )
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 |
offset |
An integer used in conjunction with |
sort_order |
A string representing the order of the resulting release
dates. Possible values are: |
include_release_dates_with_no_data |
A boolean value indicating if the
results with no data available should be returned as well.
Default is |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_releases()
, fredr_releases_dates()
, fredr_release()
,
fredr_release_series()
, fredr_release_sources()
, fredr_release_tags()
,
fredr_release_related_tags()
, fredr_release_tables()
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")) }
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
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 )
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 )
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: |
filter_value |
A string giving the value of the |
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 |
offset |
An integer used in conjunction with |
order_by |
A string indicating an attribute by which the results are ordered by. Possible values include:
|
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_releases()
, fredr_releases_dates()
, fredr_release()
,
fredr_release_dates()
, fredr_release_sources()
, fredr_release_tags()
,
fredr_release_related_tags()
, fredr_release_tables()
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" ) }
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
fredr_release_sources( release_id, ..., realtime_start = NULL, realtime_end = NULL )
fredr_release_sources( release_id, ..., realtime_start = NULL, realtime_end = NULL )
release_id |
An integer ID of the release. |
... |
These dots only exist for future extensions and should be empty. |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_releases()
, fredr_releases_dates()
, fredr_release()
,
fredr_release_dates()
, fredr_release_series()
, fredr_release_tags()
,
fredr_release_related_tags()
, fredr_release_tables()
if (fredr_has_key()) { # Where does the data for ID 10 come from? fredr_release_sources(release_id = 10L) }
if (fredr_has_key()) { # Where does the data for ID 10 come from? fredr_release_sources(release_id = 10L) }
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.
fredr_release_tables( release_id, ..., element_id = NULL, include_observation_values = NULL, observation_date = NULL )
fredr_release_tables( release_id, ..., element_id = NULL, include_observation_values = NULL, observation_date = NULL )
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 |
observation_date |
A |
A tibble
object with nested results.
fredr_releases()
, fredr_release_dates()
, fredr_releases_dates()
,
fredr_release()
, fredr_release_series()
, fredr_release_sources()
,
fredr_release_tags()
, fredr_release_related_tags()
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) }
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. Optionally, filter results by tag name, tag group, or search text.
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 )
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 )
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:
|
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 |
offset |
An integer used in conjunction with |
order_by |
Order results by values of the specified attribute. Possible values are:
|
sort_order |
A string representing the order of the resulting series,
sorted by the attribute values specified by |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_releases()
, fredr_releases_dates()
, fredr_release()
,
fredr_release_dates()
, fredr_release_series()
, fredr_release_sources()
,
fredr_release_related_tags()
, fredr_release_tables()
if (fredr_has_key()) { fredr_release_tags(release_id = 10L) }
if (fredr_has_key()) { fredr_release_tags(release_id = 10L) }
Get all releases of economic data
fredr_releases( ..., limit = NULL, offset = NULL, order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
fredr_releases( ..., limit = NULL, offset = NULL, order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
... |
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 |
offset |
An integer used in conjunction with |
order_by |
Order results by values of the specified attribute.
Possible values include: |
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_releases_dates()
, fredr_release()
, fredr_release_dates()
,
fredr_release_series()
, fredr_release_sources()
, fredr_release_tags()
,
fredr_release_related_tags()
, fredr_release_tables()
,
if (fredr_has_key()) { fredr_releases(limit = 20L) }
if (fredr_has_key()) { fredr_releases(limit = 20L) }
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.
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 )
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 )
... |
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 |
offset |
An integer used in conjunction with |
sort_order |
A string representing the order of the resulting series.
Possible values are: |
order_by |
Order results by values of the specified attribute.
Possible values include: |
include_release_dates_with_no_data |
A boolean value indicating if the
results with no data available should be returned as well. Default is |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_releases()
, fredr_release_dates()
, fredr_release()
,
fredr_release_series()
, fredr_release_sources()
, fredr_release_tags()
,
fredr_release_related_tags()
, fredr_release_tables()
if (fredr_has_key()) { fredr_releases_dates(limit = 20L) }
if (fredr_has_key()) { fredr_releases_dates(limit = 20L) }
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
.
fredr_request( endpoint, ..., to_frame = TRUE, print_req = FALSE, retry_times = 3L )
fredr_request( endpoint, ..., to_frame = TRUE, print_req = FALSE, retry_times = 3L )
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 |
to_frame |
A boolean value indicating whether or not the response should
be parsed and formatted as a data frame. If |
print_req |
A boolean value indicating whether or not the request should
be printed as well. Useful for debugging. Default is |
retry_times |
An integer indicating the maximum number of requests to
attempt. Passed directly to |
If to_frame = TRUE
, a tibble
containing the parsed response. If
to_frame = FALSE
, a response
object returned directly from
httr::GET()
.
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 ) }
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 ) }
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()
.
fredr_series(series_id, ..., realtime_start = NULL, realtime_end = NULL)
fredr_series(series_id, ..., realtime_start = NULL, realtime_end = NULL)
series_id |
A string ID for the FRED series. |
... |
These dots only exist for future extensions and should be empty. |
realtime_start |
A |
realtime_end |
A |
A tibble
object (1 row) with information for the series specified by
series_id
.
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()
.
if (fredr_has_key()) { # Return information for the "UNRATE" series fredr_series(series_id = "UNRATE") }
if (fredr_has_key()) { # Return information for the "UNRATE" series fredr_series(series_id = "UNRATE") }
Given a series ID, return information on the categories to which a series belongs
as a tibble
object.
fredr_series_categories( series_id, ..., realtime_start = NULL, realtime_end = NULL )
fredr_series_categories( series_id, ..., realtime_start = NULL, realtime_end = NULL )
series_id |
A string ID for the FRED series. |
... |
These dots only exist for future extensions and should be empty. |
realtime_start |
A |
realtime_end |
A |
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.
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()
.
if (fredr_has_key()) { # Return the categories to which the "UNRATE" series belongs fredr_series_categories(series_id = "UNRATE") }
if (fredr_has_key()) { # Return the categories to which the "UNRATE" series belongs fredr_series_categories(series_id = "UNRATE") }
Given a series ID, return observations of that series as a tibble
object.
fredr()
is an alias for fredr_series_observations()
.
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 )
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 )
series_id |
A string ID for the FRED series. |
... |
These dots only exist for future extensions and should be empty. |
observation_start |
A |
observation_end |
A |
frequency |
A string representing a lower frequency to aggregate to. Defaults to no frequency aggregation. Possible values are:
|
aggregation_method |
A string representing the aggregation method
used for frequency aggregation. This parameter has no affect is
|
limit |
An integer limit on the maximum number of results to return.
Defaults to |
offset |
An integer used in conjunction with |
sort_order |
A string representing the order of the resulting series.
Possible values are: |
units |
A string indicating the data value transformation.
Defaults to
|
realtime_start |
A |
realtime_end |
A |
vintage_dates |
A vector of |
output_type |
An integer indicating the output type. Not used unless
|
A tibble
object with observation dates and values.
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()
.
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) ) } }
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) ) } }
Given a series ID, return information on a series as a tibble
object.
fredr_series_release( series_id, ..., realtime_start = NULL, realtime_end = NULL )
fredr_series_release( series_id, ..., realtime_start = NULL, realtime_end = NULL )
series_id |
A string ID for the FRED series. |
... |
These dots only exist for future extensions and should be empty. |
realtime_start |
A |
realtime_end |
A |
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.
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()
.
if (fredr_has_key()) { # Get release information for the "UNRATE" series fredr_series_release(series_id = "UNRATE") }
if (fredr_has_key()) { # Get release information for the "UNRATE" series fredr_series_release(series_id = "UNRATE") }
Return the FRED tags by searching for matches in series text.
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 )
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 )
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
|
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 |
offset |
An integer used in conjunction with |
order_by |
A string indicating the attribute to order results by.
Defaults to
|
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
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.
API Documentation:
fredr_series_search_text()
, fredr_series_search_id()
, fredr_series_search_related_tags()
, fredr_tags()
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" ) }
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" ) }
Search FRED for a series by full text of series or by series ID.
fredr_series_search_text( search_text, ..., tag_names = NULL, exclude_tag_names = NULL, filter_variable = NULL, filter_value = NULL, limit = NULL, offset = NULL, order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL ) fredr_series_search_id( search_text, ..., limit = 1000L, offset = 0, order_by = NULL, sort_order = "asc", filter_variable = NULL, filter_value = NULL, realtime_start = NULL, realtime_end = NULL, tag_names = NULL, exclude_tag_names = NULL )
fredr_series_search_text( search_text, ..., tag_names = NULL, exclude_tag_names = NULL, filter_variable = NULL, filter_value = NULL, limit = NULL, offset = NULL, order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL ) fredr_series_search_id( search_text, ..., limit = 1000L, offset = 0, order_by = NULL, sort_order = "asc", filter_variable = NULL, filter_value = NULL, realtime_start = NULL, realtime_end = NULL, tag_names = NULL, exclude_tag_names = NULL )
search_text |
A string containing the words to match against economic
data series. For use with |
... |
These dots only exist for future extensions and should be empty. |
tag_names |
A semicolon delimited string of tag names that series match all of. Defaults to no tag filtering. |
exclude_tag_names |
A semicolon delimited string of tag names that series match none of. Defaults to no tag filtering. |
filter_variable |
A string indicating the attribute to filter results
by. Possible values are: |
filter_value |
The value of the |
limit |
An integer limit on the maximum number of results to return.
Defaults to |
offset |
An integer used in conjunction with |
order_by |
A string indicating the attribute to order results by.
Defaults to
|
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
A tibble
object where each row represents a series matching the query.
API Documentation:
fredr_series_observations()
, 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()
.
if (fredr_has_key()) { # search for series with text matching "oil" and return the top 10 most popular # series fredr_series_search_text( search_text = "oil", order_by = "popularity", limit = 10 ) # search for series with text matching "oil" with the tag "usa" and return the # top 10 search results fredr_series_search_text( search_text = "oil", order_by = "search_rank", limit = 10, tag_names = "usa" ) # search for series with text matching "unemployment" and return only series # with monthly frequency fredr_series_search_text( search_text = "unemployment", filter_variable = "frequency", filter_value = "Monthly" ) # search for series ID matching "UNRATE" and return oldest series first fredr_series_search_id( search_text = "UNRATE", order_by = "observation_start" ) }
if (fredr_has_key()) { # search for series with text matching "oil" and return the top 10 most popular # series fredr_series_search_text( search_text = "oil", order_by = "popularity", limit = 10 ) # search for series with text matching "oil" with the tag "usa" and return the # top 10 search results fredr_series_search_text( search_text = "oil", order_by = "search_rank", limit = 10, tag_names = "usa" ) # search for series with text matching "unemployment" and return only series # with monthly frequency fredr_series_search_text( search_text = "unemployment", filter_variable = "frequency", filter_value = "Monthly" ) # search for series ID matching "UNRATE" and return oldest series first fredr_series_search_id( search_text = "UNRATE", order_by = "observation_start" ) }
Given a series ID, return associated tags for the series as a tibble
object.
fredr_series_tags( series_id, ..., order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
fredr_series_tags( series_id, ..., order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
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 |
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
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.
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()
.
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") }
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") }
Returns information on the recently updated series on the FRED server.
fredr_series_updates( ..., filter_value = NULL, start_time = NULL, end_time = NULL, limit = NULL, offset = NULL, realtime_start = NULL, realtime_end = NULL )
fredr_series_updates( ..., filter_value = NULL, start_time = NULL, end_time = NULL, limit = NULL, offset = NULL, realtime_start = NULL, realtime_end = NULL )
... |
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
|
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 |
offset |
An integer used in conjunction with |
realtime_start |
A |
realtime_end |
A |
A tibble
object where each row represents a series. Rows are sorted
with most recently updated series appearing first.
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()
.
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))) }
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))) }
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.
fredr_series_vintagedates( series_id, ..., limit = NULL, offset = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
fredr_series_vintagedates( series_id, ..., limit = NULL, offset = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
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 |
offset |
An integer used in conjunction with |
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
A tibble
object where each row is a distinct vintage date.
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()
.
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") }
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
fredr_source(source_id, ..., realtime_start = NULL, realtime_end = NULL)
fredr_source(source_id, ..., realtime_start = NULL, realtime_end = NULL)
source_id |
An integer ID for the data source. |
... |
These dots only exist for future extensions and should be empty. |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_sources()
, fredr_source_releases()
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")) }
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
fredr_source_releases( source_id, ..., limit = NULL, offset = NULL, order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
fredr_source_releases( source_id, ..., limit = NULL, offset = NULL, order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
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 |
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 |
order_by |
A string indicating which attribute should be used to order the results. Possible values:
|
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_sources()
, fredr_source()
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")) }
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
fredr_sources( ..., limit = NULL, offset = NULL, order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
fredr_sources( ..., limit = NULL, offset = NULL, order_by = NULL, sort_order = NULL, realtime_start = NULL, realtime_end = NULL )
... |
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 |
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 |
order_by |
A string indicating which attribute should be used to order
the results. Possible values: |
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
A tibble
object.
fredr_source()
, fredr_source_releases()
if (fredr_has_key()) { fredr_sources(limit = 20L) }
if (fredr_has_key()) { fredr_sources(limit = 20L) }
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
.
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 )
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 )
... |
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:
|
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 |
offset |
An integer used in conjunction with |
order_by |
Order results by values of the specified attribute. Possible values are:
|
sort_order |
A string representing the order of the resulting series,
sorted by the attribute values specified by |
realtime_start |
A |
realtime_end |
A |
A tibble
containing tags and their descriptions. Data include tag
name, group ID, popularity, series count, tag creation date, and additional
notes.
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()
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") }
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") }
Get the series matching tags in the tag_names
parameter. Exclude tags in the
exclude_tag_names
parameter.
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 )
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 )
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 |
offset |
An integer used in conjunction with |
order_by |
A string indicating which attribute by which to order the results of the query. Possible values include:
|
sort_order |
A string representing the order of the resulting series,
sorted by the attribute values specified by |
realtime_start |
A |
realtime_end |
A |
A tibble
object containing FRED series with tags matching tag_names
and their descriptions.
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()
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 ) }
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 ) }
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
.
fredr_set_key(key) fredr_get_key() fredr_has_key()
fredr_set_key(key) fredr_get_key() fredr_has_key()
key |
A valid FRED API key as a string. Obtain one at the API Keys page. Can also be |
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.
See St. Louis Fed Web Services API Keys to obtain an API key.
Note that by using a FRED API key, you agree to the FRED API Terms of Use.
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)
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)