A Julia interface for retrieving data from the U.S. Bureau of Economic Analysis (BEA) Data API.
|Repo Status||Build Status||Coverage|
At the Julia REPL:
(v1.0) pkg> add BeaData
A valid registration key is required to use the BEA's API. A key can be obtained by registering here.
For now, the package only retrieves full tables from the standard National Income and Product Accounts (NIPA) (i.e., no downloads of individual data series or from other BEA datasets).
Initialize a connection
Initialize a connection to the BEA API:
b = Bea("your-36-character-registration-key")
Alternatively, you can save your key in the file
~/.beadatarc and call the constructor
with no argument:
b = Bea()
Retrieve a table
Download a NIPA table using the
mytable = get_nipa_table(b::Bea, TableName::AbstractString, frequency::AbstractString, startyear::Int, endyear::Int)
TableName: the string TableName for the desired NIPA table (see "NIPA Table Names" below)
frequency: "A" for annual, "Q" for quarerly
startyear: first year of data requested, in YYYY format
endyear: last year of data requested, in YYYY format
The method returns an object of type
BeaTable, with the following fields:
tablenum: Table number
tabledesc: Table description
OrderedDictwith table line numbers and the corresponding variable descriptions
OrderedDictwith any notes to the table
DataFramecontaining the data values; column names are the line numbers from the table (see "NIPA Table line numbers" below)
NIPA Table Names
TableNames necessary to retrieve data from the API are not exactly the same as the NIPA
table numbers. The general pattern for many tables is to replace the periods in the table number
with zeros and add "T" to the beginning. For example, the
TableName for Table 1.1.5 is "T10105".
(this pattern does not hold for all tables, however, so check the BEA site).
NIPA Table line numbers
DataFrame returned by a call to the API has dates in the first column and
the table data in the remaining columns. Data columns are named for the corresponding
line numbers of the NIPA table (e.g.,
BeaData.jl is not affiliated with, officially maintained, or otherwise supported by the Bureau of Economic Analysis.