BLS Featuring My R API Wrapper

I was in the process of cleaning up my package for submission to CRAN when I learned that the BLS has released v2 of their API service.  This version requires a key but allows for more requests plus annual average calculations which is cool.

I was shocked and gratified to see that under the Sample Code: R page they were featuring my work with this acknowledgement:


My submission to CRAN has not accepted yet, but I’m still working on it.  In the mean time it is available through GitHub.


BLS API Wrapper for R

I have created my first R package! It is called blsAPI and is available through GitHub.  It allows people to request series from the BLS’s API.

To use the function you need to specify the series id(s) and optionally the start and end years.  The following are some example of how you could use this package (these examples are taken from

Single Series

response <- blsAPI('LAUCN040010000000005')
json <- fromJSON(response)

Multiple Series

payload <- list('seriesid'=c('LAUCN040010000000005','LAUCN040010000000006'))
response <- blsAPI(payload)
json <- fromJSON(response)

One or More Series, Specifying Years

payload <- list('seriesid'=c('LAUCN040010000000005','LAUCN040010000000006'), 'startyear'='2010', 'endyear'='2012')
response <- blsAPI(payload)
json <- fromJSON(response)

Getting and Cleaning Data Course Complete

After a short delay in grading I received notification that I have completed the Getting and Cleaning Data Course.

Getting and Cleaning Data Course Record

This class explained how to pull in data from a variety of formats (i.e. excel, XML, JSON, MySQL, etc.).  It introduced me to the data.table package in R which is awesome.  It was not always taught in a very clear way.

I was taking Core Concepts in Data Analysis at the same time which was very challenging.  That is why my blog has fell silent for the last little bit (because I was too busy to write).  I am waiting to see how that class turns out.

I have been using the skills gained in this class to write scripts to pull data from the BEA’s API using R.  Hopefully I will have more to share on this in a later post.


Quick Update

My blog has been quiet lately because I have been really busy.  I bit off a little more than I could chew in the Coursera courses.  As they are coming to a close I feel a lot less pressure (it’s hard working full-time with a family and carry a course load).

I have, however, learned a lot that I am putting into practice on the job.  I have constructed cost projection models using R which was a lot easier than because what I used to do by eye I was able to program a function to do.  I have written and used R scripts that use Google’s geocoding API.

I am confident that I am moving on from R novice however I am not a master.  At least not yet.



I have begun developing a R wrapper for the FRED API.  It is hosted on GitHub at:  You will need to sign up for a FRED API key to use the wrapper.

Let’s say you want to pull Annual Real Gross National Product. Here’s how you could do it:

> fred <- fredAPI()
> fred$key('My FRED API key here')
> xml <- fred$series_observations('GNPCA')