Skip to contents

Calls the CKAN package_search Action verb against a portal base URL and returns the raw result list (count, results, etc.). For a flattened metadata data.frame, use morie_ingest_ckan_search_packages.

Usage

morie_ingest_ckan_package_search(
  portal,
  query = NULL,
  fq = NULL,
  rows = 100L,
  start = 0L,
  api_key = NULL,
  user_agent = .MORIE_CKAN_DEFAULT_UA,
  timeout = .MORIE_CKAN_DEFAULT_TIMEOUT
)

Arguments

portal

Base URL of the CKAN portal, e.g. "https://open.canada.ca/data". Trailing slash optional.

query

Free-text q= query, or NULL.

fq

CKAN fq= filter query (Solr-style), or NULL.

rows

Maximum rows to return (default 100).

start

Pagination offset (default 0).

api_key

Optional CKAN API key (rare for open portals).

user_agent

User-Agent header sent with the request.

timeout

HTTP timeout in seconds.

Value

A named list as returned by the CKAN Action API.

Examples

# \donttest{
if (requireNamespace("httr2", quietly = TRUE)) withAutoprint({
# a live portal: the example reports, rather than fails, when it is away
res <- tryCatch(
  morie_ingest_ckan_package_search("https://open.canada.ca/data",
                                   query = "corrections"),
  error = function(e) {
    message("open.canada.ca not reachable: ", conditionMessage(e))
    NULL
  }
)
if (!is.null(res)) length(res$results)
})
#> > res <- tryCatch(morie_ingest_ckan_package_search("https://open.canada.ca/data", 
#> +     query = "corrections"), error = function(e) {
#> +     message("open.canada.ca not reachable: ", conditionMessage(e))
#> +     NULL
#> + })
#> > if (!is.null(res)) length(res$results)
#> [1] 100
# }