R/zzz.R

Defines functions .onAttach .onLoad

#' @importFrom rlang .data abort inform warn
.onLoad <- function(libname, pkgname) {
  # Check for API key in environment
  key <- Sys.getenv("NOMIS_API_KEY")
  if (nzchar(key)) {
    options(nomisdata.api_key = key)
  }
  
  invisible()
}

#' @keywords internal
.onAttach <- function(libname, pkgname) {
  if (is.null(getOption("nomisdata.api_key"))) {
    packageStartupMessage(
      "No API key found. Guest users limited to 25,000 rows per query.\n",
      "Register at: https://www.nomisweb.co.uk/myaccount/userjoin.asp\n",
      "Then use: set_api_key('your-key')"
    )
  }
}
utils::globalVariables("PERIOD")

Try the nomisdata package in your browser

Any scripts or data that you put into this service are public.

nomisdata documentation built on Feb. 10, 2026, 5:10 p.m.