Title: | An R Client for the 'FRED' API |
Version: | 2.1.0 |
Maintainer: | Sam Boysel <sboysel@gmail.com> |
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'. |
License: | MIT + file LICENSE |
URL: | https://github.com/sboysel/fredr |
BugReports: | https://github.com/sboysel/fredr/issues |
Depends: | R (≥ 3.2.2) |
Imports: | httr, jsonlite, rlang, tibble |
Suggests: | covr, dplyr, ggplot2, knitr, purrr, rmarkdown, testthat, xts, zoo |
VignetteBuilder: | knitr |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.1.1 |
NeedsCompilation: | no |
Packaged: | 2021-01-29 14:39:34 UTC; davis |
Author: | Sam Boysel [aut, cre], Davis Vaughan [aut] |
Repository: | CRAN |
Date/Publication: | 2021-01-29 18:10:02 UTC |
fredr: 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'.
Author(s)
Maintainer: Sam Boysel sboysel@gmail.com
Authors:
Davis Vaughan davis@rstudio.com
See Also
Useful links:
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 returnNULL
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()
returnsTRUE
if a key can be found. Otherwise it returnsFALSE
.
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 |
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)
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
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 |
realtime_end |
A |
Value
A tibble
object containing the name and ID for the children
categories of the parent category indicated by category_id
.
API Documentation
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 related categories for a FRED category.
Description
Get the related categories for a FRED category.
Usage
fredr_category_related(
category_id,
...,
realtime_start = NULL,
realtime_end = NULL
)
Arguments
category_id |
An integer ID for the category. Default is |
... |
These dots only exist for future extensions and should be empty. |
realtime_start |
A |
realtime_end |
A |
Details
From the FRED API documentation: "A related category is a one-way relation between 2 categories that is not part of a parent-child category hierarchy. Most categories do not have related categories."
Value
A tibble
object containing the name and parent ID for categories
related to the category indicated by category_id
.
API Documentation
See Also
fredr_category()
, fredr_category_children()
,
fredr_category_series()
, fredr_category_tags()
, fredr_category_related_tags()
Examples
if (fredr_has_key()) {
# Categories related to the "Employment Cost Index" category
fredr_category_related(category_id = 4L)
}
Get the related FRED tags within a category
Description
Get the related FRED tags for one or more FRED tags within a category. Optionally, filter results by tag group or search. FRED tags are attributes assigned to series. Related FRED tags are the tags assigned to series that match all tags in the tag_names parameter, no tags in the exclude_tag_names parameter, and the category set by the category_id parameter. Series are assigned tags and categories. Indirectly through series, it is possible to get the tags for a category. No tags exist for a category that does not have series.
Usage
fredr_category_related_tags(
category_id,
tag_names,
...,
exclude_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. |
tag_names |
A string indicating which series tags to match. Multiple
tags can be delimited by a semicolon in a single string (e.g. |
... |
These dots only exist for future extensions and should be empty. |
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"“). |
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 |
Value
A tibble
object information on related tags matching the request.
Data include tag name, group ID, popularity, series count, tag creation date,
and additional notes.
API Documentation
See Also
fredr_category()
, fredr_category_children()
, fredr_category_related()
,
fredr_category_series()
, fredr_category_tags()
Examples
if (fredr_has_key()) {
# First, get the tags for the "Production & Business Activity" category
fredr_category_tags(1L)
# Then, get the tags related to "business" and "monthly" for the
# "Production & Business Activity" category
fredr_category_related_tags(category_id = 1L, tag_names = "business;monthly")
}
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: |
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 |
Value
A tibble
object with information for series matching the request for
the category specified in category_id
.
API Documentation
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. |
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 |
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
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
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 infredr_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
See Also
Get related FRED tags given one or more tags
Description
Get related FRED tags. Optionally, filter results by tag group, or
search text. Related FRED tags are the tags assigned to series that match
all tags in the tag_names
parameter and no tags in the
exclude_tag_names
parameter.
Usage
fredr_related_tags(
tag_names,
...,
exclude_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
tag_names |
A semicolon delimited string of tag names to be related to. |
... |
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. |
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 |
Value
A tibble
containing tags related to tag_names
and their
descriptions. Data include tag name, group ID, popularity, series count, tag
creation date, and additional notes.
API Documentation
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_tags()
Examples
if (fredr_has_key()) {
fredr_related_tags(tag_names = "monetary aggregates;weekly")
fredr_related_tags(
tag_names = "monetary aggregates;weekly",
tag_group_id = "gen"
)
}
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 |
realtime_end |
A |
Value
A tibble
object.
API Documentation
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 |
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 |
Value
A tibble
object.
API Documentation
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 related FRED tags for one or more FRED tags within a release
Description
FRED tags are attributes assigned to series. For this request, related FRED
tags are the tags assigned to series that match all tags in the tag_names
parameter, no tags in the exclude_tag_names
parameter, and the
release set by the release_id
parameter.
Usage
fredr_release_related_tags(
release_id,
tag_names,
...,
exclude_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. |
tag_names |
A semicolon delimited string of tag names to be related to. |
... |
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. |
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 |
Value
A tibble
object.
API Documentation
See Also
fredr_releases()
, fredr_releases_dates()
, fredr_release()
,
fredr_release_dates()
, fredr_release_series()
, fredr_release_sources()
,
fredr_release_tags()
, fredr_release_tables()
Examples
if (fredr_has_key()) {
fredr_release_related_tags(10, tag_names = "cpi")
}
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: |
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 |
Value
A tibble
object.
API Documentation
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 |
realtime_end |
A |
Value
A tibble
object.
API Documentation
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 |
observation_date |
A |
Value
A tibble
object with nested results.
API Documentation
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:
|
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 |
Value
A tibble
object.
API Documentation
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 |
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 |
Value
A tibble
object.
API Documentation
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 |
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 |
Value
A tibble
object.
API Documentation
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 |
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 |
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
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 |
realtime_end |
A |
Value
A tibble
object (1 row) with information for the series specified by
series_id
.
API Documentation
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 |
realtime_end |
A |
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
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 |
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
|
Value
A tibble
object with observation dates and values.
API Documentation
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 |
realtime_end |
A |
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
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 related FRED tags for one or more FRED tags matching a series search
Description
FRED tags are attributes assigned to series. Return the related FRED tags
for a search: tags assigned to series that match all tags in the tag_names
parameter (required), no tags in the exclude_tag_names
(optional) and the
search words set by the series_search_text
parameter (required).
Usage
fredr_series_search_related_tags(
series_search_text,
tag_names,
...,
exclude_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. |
tag_names |
A semicolon delimited string of tag names to return. |
... |
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. Defaults to no tag filtering. |
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 |
Value
A tibble
object.
References
API Documentation:
See Also
fredr_series_observations()
, fredr_series_search_text()
,
fredr_series_search_id()
, fredr_series_search_tags()
,
fredr_series()
, fredr_series_categories()
,
fredr_series_release()
, fredr_series_tags()
, fredr_series_updates()
,
fredr_series_vintagedates()
.
Examples
if (fredr_has_key()) {
# Search for all tags matching the series text "oil" and the tag "usa".
fredr_series_search_related_tags(
series_search_text = "oil",
tag_names = "usa"
)
# Search for tags matching the series text "oil", the tag text "usa", and
# are related to the tag "usa". Return only results in the "src" (Source)
# group.
fredr_series_search_related_tags(
series_search_text = "oil",
tag_names = "usa",
tag_group_id = "src",
tag_search_text = "usa"
)
}
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
|
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 |
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:
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"
)
}
Search for a FRED series.
Description
Search FRED for a series by full text of series or by series ID.
Usage
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
)
Arguments
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 |
Value
A tibble
object where each row represents a series matching the query.
References
API Documentation:
See Also
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()
.
Examples
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"
)
}
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 |
sort_order |
A string representing the order of the resulting series.
Possible values are: |
realtime_start |
A |
realtime_end |
A |
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
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
|
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 |
Value
A tibble
object where each row represents a series. Rows are sorted
with most recently updated series appearing first.
API Documentation
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 |
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 |
Value
A tibble
object where each row is a distinct vintage date.
API Documentation
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 |
realtime_end |
A |
Value
A tibble
object.
API Documentation
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 |
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 |
Value
A tibble
object.
API Documentation
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 |
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 |
Value
A tibble
object.
API Documentation
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:
|
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 |
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
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 |
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 |
Value
A tibble
object containing FRED series with tags matching tag_names
and their descriptions.
API Documentation
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
)
}