knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(tidyverse)
The goal of wtmapi
is to provide access to the public data API of Who Targets Me.
You can install the released version of wtmapi from GitHub with:
# install.packages("remotes") remotes::install_github("favstats/wtmapi")
library(wtmapi)
The main function in wtmapi
to use is wtm_get
. With it you can access the API endpoints:
candidates-impressions
candidates-targeting-methods
impressions-daily-totals
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.
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
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 the daily total impressions for a country (in this case germany):
daily_totals <- wtm_get(endpoint = "impressions-daily-totals", country = "DE") daily_totals
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.