Retrieve a GeoLocator Data Package from a Zenodo record identifier:
Resolve and fetch Zenodo record metadata from the REST API.
Download
datapackage.json, then the files its resources refer to andparams.jsonwhen the record has one, to a temporary directory. Other files of the record are not downloaded. Each file is checked against the MD5 checksum Zenodo records for it.Read
datapackage.jsonwithread_gldp(), loading every table into memory, then delete the temporary directory.Attach Zenodo metadata and recompute derived package properties with
update_gldp().
Arguments
- id
Zenodo identifier. Can be a record id, DOI, DOI URL, or Zenodo record URL. Supported examples include
"18467383","10.5281/zenodo.18467383","https://doi.org/10.5281/zenodo.18467383", and"https://zenodo.org/records/18467383". A Zenodo Sandbox record URL or DOI (prefix10.5072) is read from Zenodo Sandbox; for a bare Sandbox record id, setsandbox = TRUE.- token
Optional Zenodo access token for authenticated requests. A token given here is always used. If
NULL, a draft is read with a token resolved from environment variables or the system keyring, and a published record is read without authentication.- draft
Logical. If
TRUE, read the draft version of the record instead of the public record. This queries the draft endpoint (/api/records/{id}/draft), which requires a token and permission to access the deposition. Use this for unpublished records or when draft files or metadata differ from the published record.- sandbox
Logical. If
TRUE, query Zenodo Sandbox instead of the main Zenodo service. This also switches draft token lookup to sandbox-first sources.- quiet
Logical. If
TRUE, suppress progress messages fromread_zenodo().- timeout
Maximum time in seconds allowed to download each file.
Details
If the record has no files, because it is metadata-only or its files are restricted or embargoed, the function warns and returns a package with only metadata, created with
create_gldp().If the record does not contain
datapackage.jsonor a file it refers to, the function aborts.If one or more file downloads fail or do not match their checksum, the function aborts with download details.
Downloaded files are written under tempdir() in a run-specific folder,
which is deleted once the package is read. A resource without a table
schema, which is not loaded into memory, keeps a path into that deleted
folder.
A published record is read without authentication unless token is given,
so its restricted or embargoed files are only read with token =.
To read a draft:
Create or identify the Zenodo deposition and note its record id.
Obtain a Zenodo access token with permission to view that draft.
Provide the token directly with
token =, or make it available asZENODO_TOKEN(main Zenodo) orZENODO_TOKEN_SANDBOX(Zenodo Sandbox). The same names are also checked in the system keyring.Call
read_zenodo(id, draft = TRUE), and setsandbox = TRUEwhen the draft is hosted on Zenodo Sandbox.
If draft = TRUE and token = NULL, token lookup is attempted in this order:
for main Zenodo:
ZENODO_TOKEN, then keyring serviceZENODO_TOKEN;for Zenodo Sandbox:
ZENODO_TOKEN_SANDBOX,ZENODO_TOKEN, then keyring servicesZENODO_TOKEN_SANDBOXandZENODO_TOKEN.
See also
read_gldp() to read a local or remote datapackage.json, and
create_gldp() for the empty package shell used when record files are not
accessible.
Examples
if (FALSE) { # \dontrun{
pkg <- read_zenodo("18467383", quiet = TRUE)
# Resolve from DOI URL
pkg <- read_zenodo("https://doi.org/10.5281/zenodo.18467383", quiet = TRUE)
# Access a draft in Zenodo Sandbox using a token from the environment/keyring
pkg <- read_zenodo("470406", sandbox = TRUE, draft = TRUE, quiet = TRUE)
# Or provide the token explicitly
pkg <- read_zenodo(
"470406",
sandbox = TRUE,
draft = TRUE,
token = "<TOKEN>",
quiet = TRUE
)
} # }
