Description Usage Arguments Value API Documentation Examples
View source: R/fredr_request.R
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
.
1 2 3 4 5 6 7 | 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()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.