wtm_get: wtm_get

Description Usage Arguments Examples

View source: R/api.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
wtm_get(
  endpoint,
  country = NULL,
  party = NULL,
  limit = NULL,
  skip = NULL,
  selects = NULL,
  sort_by = NULL,
  sort_dir = 1,
  values_in_var = NULL,
  values_nin_var = NULL,
  lt = NULL,
  lte = NULL,
  gt = NULL,
  gte = NULL,
  ne = NULL,
  or = NULL,
  ...,
  raw = F
)

Arguments

endpoint

the API endpoint you want to retrieve. currently supports: candidates-impressions, candidates-targeting-methods and impressions-daily-totals.

country

which country to retrieve data from (ISO2). Examples: "DE", "US" etc.

party

which party to retrieve data from. Examples: "CDU", "Biden" etc.

limit

will return only the number of results you specify

skip

will skip the specified number of results

selects

allows to pick which fields to include in the result, chr or vector of chrs

sort_by

will sort based on the variable you provide (chr)

sort_dir

sort direction (1 ascending, -1 descending) (default = 1)

values_in_var

find all records where the property does ($in) match any of the given values. Input is a list: list(variable = c(1:3)).

values_nin_var

find all records where the property does not ($nin) match any of the given values. Input is a list: list(variable = c(1:3)).

lt

find all records where the value is less ($lt) to a given value. Input is a list: list(variable = c(1:3)).

lte

find all records where the value is less and equal ($lte) to a given value. Input is a list: list(variable = c(1:3)).

gt

find all records where the value is more ($gt) to a given value. Input is a list: list(variable = c(1:3)).

gte

find all records where the value is more and equal ($gte) to a given value. Input is a list: list(variable = c(1:3)).

ne

find all records that do not equal the given property value. Input is a list: list(variable = c(1:3)).

or

find all records that match any of the given criteria. Specify the params as chr (vector) that should be combined with an $or statement. Example: c("values_in_var", "gt").

...

additional arguments you can pass to test for equality. Example = facebookName = PragerU retrieves all entries by advertiser PragerU.

raw

whether to return the raw GET request or a tidy data frame (defaults to FALSE)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# retrieve all advertiser targeting methods in the use
# that have a greater or equal value of `bct = 1`.
wtm_get(endpoint = "candidates-targeting-methods",
        country = "US",
        gte = list(bct = 1))



# retrieve all advertiser targeting methods in the use
# that have a greater or equal value of `bct = 1` OR
# `custom_audiences_lookalike = 20`.
wtm_get(endpoint = "candidates-targeting-methods",
        country = "US",
        gte = list(bct = 1),
        value_in_var = list(custom_audiences_lookalike = 20),
        or = c("gte", "value_in_var"))

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