R/getspeciesinfo.R

Defines functions species_get_info species_get_image_data

Documented in species_get_image_data species_get_info

#' Get image metadata of a list of species
#'
#' @param species A vector of names
#' @return A data frame of image metadata(image urls, license info etc.) of species
#' @seealso \url{https://github.com/phylotastic/phylo_services_docs/tree/master/ServiceDescription} or \url{https://eol.org/api/}
#' @export
species_get_image_data <- function(species) {
  spec.string <- paste(species, collapse="|")
  results <- jsonlite::fromJSON(paste0(get_base_url(), 'si/eol/get_images?species=', utils::URLencode(spec.string)))

  return(results$species)
}

#' Get information from Encyclopedia of Life of a list of species
#'
#' @param species A vector of names
#' @return A data frame of species information from Encyclopedia of Life. Type of information available varies among species.
#' @seealso \url{https://github.com/phylotastic/phylo_services_docs/tree/master/ServiceDescription} or \url{https://eol.org/api/}
#' @export
species_get_info <- function(species) {
  spec.string <- paste(species, collapse="|")
  results <- jsonlite::fromJSON(paste0(get_base_url(), 'sl/eol/get_links?species=', utils::URLencode(spec.string)))

  return(results$species)
}
phylotastic/rphylotastic documentation built on Aug. 22, 2023, 9:51 p.m.