fredr_request: Send a request to the FRED API

Description Usage Arguments Value API Documentation Examples

View source: R/fredr_request.R

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 return is either the response object from GET or the response parsed as a tibble.

Usage

1
fredr_request(endpoint, ..., to_frame = TRUE, print_req = FALSE)

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 param_key = "param_value". Acceptable parameters are endpoint-specific. See the fredr_endpoints data frame for a list of endpoints and fredr_docs() access to the web documentation for each endpoint function.

to_frame

A boolean value indicating whether or not the response should be parsed and formatted as a data frame. If FALSE, a response object is returned and further processing can be done with content. Default is TRUE.

print_req

A boolean value indicating whether or not the request should be printed as well. Useful for debugging. Default is FALSE.

Value

If to_frame = TRUE, a tibble containing the parsed response. If to_frame = FALSE, a response object returned directly from GET.

API Documentation

FRED API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
fredr_request(
  endpoint = "series/observations",
  series_id = "GNPCA",
  observation_start = "1990-01-01",
  observation_end = "2000-01-01"
)
# Compare with to_frame = TRUE
resp <- fredr_request(
  endpoint = "series/observations",
  series_id = "GNPCA",
  observation_start = "1990-01-01",
  observation_end = "2000-01-01",
  to_frame = FALSE
)

fredr documentation built on May 2, 2019, 7:29 a.m.