knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

library(tidyverse)

wtmapi

Lifecycle: experimental

The goal of wtmapi is to provide access to the public data API of Who Targets Me.

Installation

You can install the released version of wtmapi from GitHub with:

# install.packages("remotes")
remotes::install_github("favstats/wtmapi")

Examples

library(wtmapi)

The main function in wtmapi to use is wtm_get. With it you can access the API endpoints:

Here are some basic examples which show you how to solve a common problems. If you have questions, refer to the docs which will help you with the query parameter.

Retrieve impressions

Let's say we want to retrieve all ads with less than (lt) 20 impressions from the party "CDU" in Germany:

impressions_dat <- wtm_get(endpoint = "candidates-impressions", 
               country = "DE", 
               party = "CDU",
               lt = list(impressions = 20))

impressions_dat

Retrieve targeting methods

Let's say we want to retrieve all ads which have greater than or equal (gte) to 1 bct (which is the behavioral targeting method) in the US:

targeting_dat <- wtm_get(endpoint = "candidates-targeting-methods", 
                         country = "US",
                         gte = list(bct = 1))

targeting_dat

Retrieve daily totals

Retrieve the daily total impressions for a country (in this case germany):

daily_totals <- wtm_get(endpoint = "impressions-daily-totals", 
                        country = "DE")

daily_totals

TODO



favstats/wtmapi documentation built on Dec. 20, 2021, 7:45 a.m.