Learn R Programming

blscrapeR (version 1.0.1)

bls_api: Basic Request Mechanism for BLS Tables

Description

Return data frame from one or more requests via the US Bureau of Labor Statistics API. Provided arguments are in the form of BLS series ids.

Usage

bls_api(seriesid, startyear = NULL, endyear = NULL, registrationKey = NULL, catalog = NULL, calculations = NULL, annualaverage = NULL)

Arguments

seriesid
The BLS id of the series your trying to load. A common format would be 'LAUCN040010000000005'. WARNING: All seriesIDs must contain the same time resolution. For example, monthly data sets can not be combined with annual or semi-annual data. If you need help finding seriesIDs, check the BLS website or the BLS Data Finder--links below.
startyear
The first year in your data set.
endyear
The last year in your data set.
registrationKey
The API key issued to you from the BLS website.
catalog
Series description information available only for certian data sets.
calculations
Returns year-over-year calculations if set to TRUE.
annualaverage
Retruns an annual average if set to TRUE.

See Also

http://www.bls.gov/data/

http://beta.bls.gov/dataQuery/search

Examples

Run this code

## Not run: 
# ## API Version 1.0 R Script Sample Code
# ## Single Series request
# df <- bls_api("LAUCN040010000000005")
# 
# 
# ## API Version 1.0 R Script Sample Code
# ## Multiple Series request with date params.
# df <- bls_api(c("LAUCN040010000000005", "LAUCN040010000000006"), 
# startyear = "2010", endyear = "2012")
# 
# 
# ## API Version 1.0 R Script Sample Code
# ## Multiple Series request with date params.
# df <- bls_api(c("LAUCN040010000000005", "LAUCN040010000000006"), 
# startyear = "2010", endyear = "2012")
# 
# 
# ## API Version 2.0 R Script Sample Code
# ## Multiple Series request with full params allowed by v2.
# df <- bls_api(c("LAUCN040010000000005", "LAUCN040010000000006"),
# startyear = "2010", endyear = "2012",
# registrationKey = "BLS_KEY", 
# calculations = TRUE, annualaverage = TRUE, catalog = TRUE)
# ## End(Not run)

Run the code above in your browser using DataLab