R/api_user.R

Defines functions api_user

Documented in api_user

#' RobinHood API: User
#'
#' Backend function called by get_user() to return user data
#'
#' @param RH object of class RobinHood
#' @import httr magrittr
#' 
api_user <- function(RH) {

  # URL and token
  url <- api_endpoints("user")
  token <- paste("Bearer", RH$tokens.access_token)

  # GET call
  dta <- GET(url, add_headers("Accept" = "application/json", "Authorization" = token))

  # format return
  dta <- mod_json(dta, "fromJSON")
  dta <- as.list(dta)

  return(dta)
}

Try the RobinHood package in your browser

Any scripts or data that you put into this service are public.

RobinHood documentation built on March 1, 2021, 5:08 p.m.