Skip to contents

OSF API queries only return up to 10 items per page, so this helper functions checks for extra pages and returns all of them

Usage

osf_get_all_pages(url, page_end = Inf)

Arguments

url

the OSF API URL

page_end

The last page to get

Value

a table of the returned data. When the request could not be completed (e.g. a private, embargoed, withdrawn, or deleted resource, or a network failure), this is an empty list() with an osf_error attribute set to "forbidden", "not_found", "gone", or "request_failed" (a bare NULL cannot carry attributes in R, so it would silently discard this) – callers that only check length(result) == 0 keep working unchanged, and callers that need to tell "inaccessible" apart from "genuinely empty" can check attr(result, "osf_error").

Examples

# get the 20 newest preprints
# \donttest{
if (online("api.osf.io")) {
  osf_api <- getOption("metacheck.osf.api")
  url <- sprintf("%s/preprints/?search=date_created-desc", osf_api)
  preprints <- osf_get_all_pages(url, 2)
}
# }