nytimes icon indicating copy to clipboard operation
nytimes copied to clipboard

Error: couldn't find NYTIMES_KEY environment variable

Open ngathan opened this issue 4 years ago • 2 comments

I followed the first steps to set up the environment as follows:

apikey <- paste0("NYTIMES_KEY=", "mykey____") file <- file.path(path.expand("~"), ".Renviron") cat(apikey, file = file, append = TRUE, fill = TRUE) install.packages("devtools") devtools::install_github("mkearney/nytimes") library(nytimes) nytsearch <- nyt_search("multiculturalism", n = 2000)

But I got this error: Error: couldn't find NYTIMES_KEY environment variable

What have I done wrong?

ngathan avatar Aug 15 '20 16:08 ngathan

I used Sys.setenv(NYTIMES_KEY="MY-API-KEY") instead of the first 3 lines of code and it worked. I found that suggestion here: https://www.storybench.org/working-with-the-new-york-times-api-in-r/

sarahemlin avatar Mar 13 '22 03:03 sarahemlin

Thanks @sarahemlin!

ngathan avatar Mar 13 '22 13:03 ngathan