This function sets the SpeciesLink API key as an environment variable in the R environment. This API key is required to retrieve occurrence records from SpeciesLink.
Usage
set_specieslink_credentials(
specieslink_key,
permanently = FALSE,
overwrite = FALSE,
open_Renviron = FALSE,
verbose = TRUE
)Arguments
- specieslink_key
(character) your SpeciesLink API key.
- permanently
(logical) whether to add the SpeciesLink API key permanently to the R environment. Default is
FALSE, meaning it will be added only temporarily for the current session.- overwrite
(logical) whether to overwrite SpeciesLink credential if it already exists. Only applicable if
permanentlyis set toTRUE. Default isFALSE.- open_Renviron
(logical) whether to open the .Renviron file after saving the credential. Only applicable if
permanentlyis set toTRUE. Default isFALSE.- verbose
(logical) if
TRUE, prints messages about the progress and the number of species being checked. Default isTRUE.
Value
If permanently and open_Renviron are set to TRUE, it opens the .Renviron
file. Otherwise, the credentials are saved silently.
Details
To check your API key, visit: https://specieslink.net/aut/profile/apikeys.
Examples
if (FALSE) { # \dontrun{
# Set your speciesLink API key (required before running this function)
# set_specieslink_credentials(specieslink_key = "your_api_key")
# Retrieve records for Arecaceae in São Paulo
res <- get_specieslink(
family = "Arecaceae",
country = "Brazil",
stateProvince = "São Paulo",
basisOfRecord = "PreservedSpecimen",
limit = 10
)
# Save results as compressed CSV
get_specieslink(
family = "Arecaceae",
country = "Brazil",
save = TRUE,
dir = tempdir(),
filename = "arecaceae_sp",
compress = TRUE
)
} # }
