fredr provides a complete set of R bindings to the Federal Reserve of Economic Data (FRED) RESTful API, provided by the Federal Reserve Bank of St. Louis. The functions allow the user to search for and fetch time series observations as well as associated metadata within the FRED database.
The core function in this package is fredr()
, which fetches observations for a FRED series. That said, there are many other FRED endpoints exposed through fredr, such as fredr_series_search_text()
, which allows you to search for a FRED series by text.
We strongly encourage referencing the FRED API documentation to leverage the full power of fredr.
You’ll also need a free API key to use fredr. See ?fredr_set_key()
.
You can download fredr from CRAN with:
To get the development version of the package:
You can use fredr()
to fetch series from FRED. This fetches the US unemployment rate series from 1990-2000.
library(fredr)
fredr(
series_id = "UNRATE",
observation_start = as.Date("1990-01-01"),
observation_end = as.Date("2000-01-01")
)
#> # A tibble: 121 x 5
#> date series_id value realtime_start realtime_end
#> <date> <chr> <dbl> <date> <date>
#> 1 1990-01-01 UNRATE 5.4 2021-01-29 2021-01-29
#> 2 1990-02-01 UNRATE 5.3 2021-01-29 2021-01-29
#> 3 1990-03-01 UNRATE 5.2 2021-01-29 2021-01-29
#> 4 1990-04-01 UNRATE 5.4 2021-01-29 2021-01-29
#> 5 1990-05-01 UNRATE 5.4 2021-01-29 2021-01-29
#> 6 1990-06-01 UNRATE 5.2 2021-01-29 2021-01-29
#> 7 1990-07-01 UNRATE 5.5 2021-01-29 2021-01-29
#> 8 1990-08-01 UNRATE 5.7 2021-01-29 2021-01-29
#> 9 1990-09-01 UNRATE 5.9 2021-01-29 2021-01-29
#> 10 1990-10-01 UNRATE 5.9 2021-01-29 2021-01-29
#> # … with 111 more rows
See the Get started article.
See the documentation site.
According to the FRED team, the following data sources do not permit redistribution through the FRED API:
If you need data from any of these sources, it is recommended to download the data directly from the FRED website. The series in these sources can be found here.
Please note that the fredr project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
There are several other existing R packages designed for the FRED API: