R/apptweak_api.R

Defines functions apptweak_api

Documented in apptweak_api

#' apptweak_api_content
#'
#' Download the app content from AppTweak - due to API restrictions it is best to pull the API content with this function and then use others to extract the relevant parts of the data
#' @param api_token Your AppTweak API token
#' @param os Either 'ios' or 'android'
#' @param to_return Either 'content' or 'metadata'. Defaults to 'content'
#' @export

apptweak_api <- function(api_token,os,to_return='content',language='DE') {

  library(httr)
  library(jsonlite)

  language <- str_to_upper(language)

  os <- str_to_lower(os)

  app_id <- ifelse(os == 'android','de.commerzbanking.mobil','366609901')

  request <- paste('https://api.apptweak.com/',os,'/applications/',app_id,'.json?country=DE&language=',language,sep='')

  x <- GET(request,add_headers('X-Apptweak-Key'=api_token))

  y <- content(x,'parsed')

  if (to_return == 'metadata') {
    z <- y$metadata
  } else {
    z <- y$content
  }

return(z)

}
neugelb/neugelbtools documentation built on July 7, 2020, 1:17 a.m.