Search code examples
rproxyportquandl

How to set the proxy port and URL in R for the blsAPI


My employer's firewall requires I set the proxy port and url when downloading data in R using the Quandl package. I'm now trying to use the blsAPI package and the work around I used for Quandl is not working. How do I set the proxy port and URL for the blsAPI package?

Below see the code I use for Quandl:

proxyURL <- "##.#.##.###"
proxyPort <- ####,
set_config(use_proxy(url = proxyURL, proxyPort))

Below see the error I get using the blsAPI:

> response <- blsAPI('LAUCN040010000000005')
Error in function (type, msg, asError = TRUE)  : 
  Failed to connect to api.bls.gov port 80: Timed out

Solution

  • Found a solution, see code below:

    proxyURL <- "##.#.##.###"
    proxyPort <- ####
    Sys.setenv(http_proxy = paste(proxyURL, proxyPort, sep = ":"))
    

    I can now use the blsAPI.