rmytarget - R пакет для работы с API MyTarget v2

Подробная русскоязычная документация находится по ссылке.

Виньетки

Помимо основной документации пакет содержит 2 виньетки:

Для просмотра виньеток запустите в R одну из следующих команд:

vignette('rmytarget-auth', package = 'rmytarget')

vignette('rmytarget-intro', package = 'rmytarget')

Функции пакета rmytarget

На данный момент в пакете rmytarget доступно 5 функций:

Пример работы с пакетом rmytarget

# work with simple client account
# authorize by ad account
myTarAuth(login = "client_login")

# get campaing list
campaing <- myTarGetCampaignList(login = "client_login")

# get ads list
ads      <- myTarGetAdList(login = "client_login")

# load statistic
# load base stat by ads
old_data    <- myTarGetStats(date_from   = Sys.Date() - 7,
                             date_to     = Sys.Date(),
                             object_type = "banners",
                             object_id   = campaing$id,
                             login       = "client_login")

# load base, tps, and viral metrics by campaings
custom_data <- myTarGetStats(date_from   = Sys.Date() - 7,
                             date_to     = Sys.Date(),
                             object_type = "campaigns",
                             metrics     = c("base", "tps", "viral"),
                             stat_type   = "day",
                             login       = "client_login")

# load all metrics by campaigns
all_data <- myTarGetStats(date_from   = Sys.Date() - 7,
                          date_to     = Sys.Date(),
                          object_type = "campaigns",
                          metrics     = "all",
                          login       = "client_login")

# ========================
# work with agency account
# authorize by agency account
myTarAuth(login = "agency_login")

# load client list from agency account 
clients <- myTarGetClientList(login = "agency_login")

# load statistic by agency clients
client_stat <-  myTarGetStats(date_from   = Sys.Date() - 7,
                              date_to     = Sys.Date(),
                              object_id   = clients$id,
                              object_type = "users",
                              metrics     = "all",
                              login       = "agency_login")