Send a request to the FRED API
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 )
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 ) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.