R/vocab_api.R

Defines functions api_url vocab_api

Documented in vocab_api

#' Build a SAG web service url
#'
#' utility to build a url with optional query arguments
#'
#' @param service the name of the service
#' @param ... name arguments will be added as queries
#'
#' @return a complete url as a character string
#'
#' @examples
#'
#' vocab_api("hi", bye = 21)
#' vocab_api("CodeType")
#'
#' @importFrom httr parse_url build_url
#' @export
vocab_api <- function(service, ...) {
  url <- paste0(api_url(), "/", service)
  url <- parse_url(url)
  url$query <- list(...)
  url <- build_url(url)

  url
}

api_url <- function() {
  "https://vocab.ices.dk/services/api"
}

Try the icesVocab package in your browser

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

icesVocab documentation built on June 8, 2025, 11:25 a.m.