Skip to contents

Retrieve data from the EIA API

Usage

eia2(
  route = "",
  facets = list(),
  data_cols = character(),
  frequency = NULL,
  start = NULL,
  end = NULL,
  sort = data.frame(column = "period", direction = "desc"),
  offset = 0,
  length = 5000,
  out = "json",
  api_key = eia_get_key()
)

Arguments

route

to base dataset

facets

list of facet filter specifications

data_cols

names of data columns to retrieve

frequency

data frequency

start

filter start of data requested

end

filter end of data requested

sort

data frame specifying sorting

offset

starting position, for paged results

length

number of data points to retrieve

out

output data format, "json" or "xml"

api_key

character api key

See also

request, eia2_req_perform(), and eia2_resp_data() provide a stepwise workflow to build a request, perform it, and extract formatted data.

Examples

if (FALSE) {
eia2("electricity/retail-sales", data_cols = "price", length = 10)
}