R/iextrader_endpoints.R

#' Get Historical Stock Prices from IEXTrader
#'
#' @param type (string) endpoint you want to return
#' @export
iextrader_endpoints <- function(type) {
  # iextrader website
  url <- "https://api.iextrading.com/1.0/"

  # endpoints
  endpoints <- list(
    historical    = "stock/'stock'/chart/5y/",
    financials    = "stock/'stock'/financials/",
    stats         = "stock/'stock'/stats/",
    symbols       = "ref-data/symbols/",
    company       = "stock/'stock'/company",
    delayed_quote = "stock/'stock'/delayed-quote"
  )

  # identify the list index of the endpoint
  x <- which(names(endpoints) == type)

  # combine into the url
  url <- paste(url, endpoints[x], sep = "")

  return(url)
}
JestonBlu/IEXTrader documentation built on May 29, 2019, 1:20 p.m.