A function to download data from the Energy Information Administration's (EIA's) API.

Share:

Description

A function to download data from the EIA's API. Resulting time series are of class xts.

Usage

1
getEIA(ID, key)

Arguments

ID

The EIA API Series ID for the data.

key

Your EIA API key.

Value

xts object (time series)

Author(s)

Matthew Brigida

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## The function is currently defined as
function (ID, key) 
{
    switch(.last_char(ID), A = .getAnnEIA(ID, key = key), Q = .getQEIA(ID, 
        key = key), M = .getMonEIA(ID, key = key), W = .getWDEIA(ID, 
        key = key), D = .getWDEIA(ID, key = key),
        print("ERROR: The last
        character of your ID is not one of the possible sampling
        frequencies (A, Q, M, W, or D)"))
  }