Skip to content

Interface to the 'Campaign Monitor' API

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

AmnestyAustralia/campaignmonitor

Repository files navigation

campaignmonitor

Lifecycle: experimental

campaignmonitor is an R wrapper for the Campaign Monitor API (CM).

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("AmnestyAustralia/campaignmonitor")

Example

library(campaignmonitor)

# Configure
cm_set_config(
  list(
    cm_host = "https://api.createsend.com/api/v3.3/",
    cm_api_key = "xxxx"
  )
)

cm_set_client_id(cm_clients()[1, "ClientID"])

# Get all lists for the current client ID
cm_lists()

# Get list statistics
my_list_id <- cm_list_by_name("My list")
cm_list_stats(my_list_id)

Configuration

Credentials

campaignmonitor requires the base URL for the CM API and an API key to be set. These can be set with cm_set_config(), which accepts a list with cm_host and cm_api_key elements.

cm_set_config(
  list(
    cm_host = "https://api.createsend.com/api/v3.3/",
    cm_api_key = "xxxx"
  )
)

Since a list is used it is simple to load credentials directly from a YAML file with the yaml package.

# cm_credentials.yml
cm_host: "https://api.createsend.com/api/v3.3/"
cm_api_key: "xxxx"
cm_set_config(yaml::read_yaml("cm_credentials.yml"))

ClientID

Many CM API endpoints require a client ID, for example retrieving lists and campaigns for your account. Since a single client ID will generally be used a default can be set with cm_set_client_id(), which will then be used as the default for functions taking a client_id argument.

cm_set_client_id("xxxx")

The default client ID can also be set alongside the host URL and API key.

cm_set_config(
  list(
    cm_host = "https://api.createsend.com/api/v3.3/",
    cm_api_key = "xxxx",
    cm_client_id = "ab12cd34ef56gh78ij90kl12mn34op56"
  )
)

If you are unsure of your client ID you can use cm_clients() to retrieve a data frame with the name and ID of client accounts accessible with the current API key.

# Set the default client ID to the first available client
cm_set_client_id(cm_clients()[1, "ClientID"])

About

Interface to the 'Campaign Monitor' API

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages