Learn R Programming

blscrapeR (version 4.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 = FALSE,
  calculations = FALSE,
  annualaverage = FALSE,
  ...
)

Value

A tibble from the BLS API.

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 certain data sets.

calculations

Returns year-over-year calculations if set to TRUE.

annualaverage

Returns an annual average if set to TRUE.

...

additional arguments

Examples

Run this code


## API Version 1.0 R Script Sample Code
## Single Series request
df <- bls_api("LAUCN040010000000005")

if (FALSE) {
## 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)
}

Run the code above in your browser using DataLab