Package 'op3r'

Title: R Interface to the OP3 API
Description: The op3r package provides a tidy interface to the Open Prefix Project (OP3) API.
Authors: Eric Nantz [aut, cre], John Spurlock [ctb] (Author of OP3 project)
Maintainer: Eric Nantz <[email protected]>
License: MIT + file LICENSE
Version: 0.1.1
Built: 2024-11-22 03:52:09 UTC
Source: https://github.com/rpodcast/op3r

Help Index


Obtain OP3 API token

Description

Obtain the OP3 API token from a .Renviron file, either stored in the current directory or the user's home directory.

Usage

get_op3_token()

Value

list with API token


Get monthly and weekly show download counts

Description

op3_downloads_show() obtains the number of monthly downloads and average weekly downloads over the last four weeks (excludes bots)

Usage

op3_downloads_show(show_id, nest_downloads = TRUE)

Arguments

show_id

One or more character strings of OP3 show UUID values

nest_downloads

Boolean to create a list column of the weekly download metrics or expand the data frame to have one row per week of download metrics. Default is TRUE.

Value

tibble data frame with the following columns:

  • days: Number of days in time window

  • monthlyDownloads: Number of downloads in month

  • weeklyAvgDownloads: Average number of downloads per week in month

  • numWeeks: Number of weeks in time window

  • download_data: Nested data frame of download numbers per week (when nest_downloads is TRUE)

  • weekNumber: Week number in time window (when nest_downloads is FALSE)

  • weeklyDownloads: Number of downloads for weekNumber (when nest_downloads is FALSE)

Examples

# Requires API token

op3_downloads_show(show_id = "a18389b8a52d4112a782b32f40f73df6")

Get podcast OP3 UUID from Podcast GUID or RSS Feed

Description

op3_get_show_uuid() uses the API to obtain the podcast OP3 UUID based on either the podcast GUID or podcast RSS feed. Only one of the two can be specified.

Usage

op3_get_show_uuid(show_guid = NULL, show_rss_url = NULL)

Arguments

show_guid

String representing the podcast GUID.

show_rss_url

String representing the podcast RSS feed

Value

string with the podcast UUID


Get log record metadata for OP3 service

Description

op3_hits() obtains lowest-level log records for every prefix redirect processed by the OP3 service.

Usage

op3_hits(
  format = "json",
  limit = 100,
  desc = TRUE,
  start = NULL,
  start_inclusive = TRUE,
  end = NULL,
  url = NULL,
  hashed_ip_address = NULL
)

Arguments

format

result output format returned by the API endpoint. Possible values are json (object-based) or json-a (array-based) formats.

limit

Integer of maximum number of episodes to return. The maximum limit supported for this endpoint is 1000. Default is 100.

desc

Boolean to return results in time-descending order. If FALSE, results are returned in time-ascending order. Default is TRUE.

start

Optional date or date-time object to filter results to those starting at the supplied value. The object must be class Date. Default is NULL.

start_inclusive

Boolean to consider the start date or date-time as inclusive for results. If FALSE, the start value is considered exclusive. Default is TRUE.

end

Optional date or date-time object to filter results to those ending at the supplied value. The object must be class Date. Default is NULL.

url

Optional string to filter results by the specific URL providing the redirect. The URL is often a direct link to a podcast episode file, or a version of the URL with a wildcard character * to enable multiple episodes for a given podcast. Default is NULL.

hashed_ip_address

Optional string to filter results by the specific IP address secure hash. Default is NULL.

Value

Atibble data frame for the json format, otherwise a nested list for the json-a format. The data frame contains the following columns:

  • time: Timestamp of current record

  • uuid: OP3 UUID for podcast

  • hashedIpAddress: Secure hash of the record's originating IP address

  • method: Type of HTTP method used

  • url: URL of the record's request

  • userAgent: Request's reported user agent

  • range: If application, the request's specified bytes range.

  • edgeColo: Three-letter airport code associated with the record

  • continent: The request's originating continent

  • country: Two-letter country code of the record

  • timezone: Request timezone

  • regionCode: Abbreviation of region

  • region: Region of request

  • metroCode: Region metro code

Examples

# Requires API token

# obtain 10 records
op3_hits(limit = 10)

# records based on specific podcast episode
op3_hits(url = "https://op3.dev/e/serve.podhome.fm/episode/99cfd30f-e40c-426a-3557-08dc4ea63bb0/63851340872787683054574074-0a1f-4951-8f2a-9084678c6604v1.mp3")

# records for multiple episodes using a wildcard in URL
op3_hits(url = "https://op3.dev/e/serve.podhome.fm/episode/99cfd30f-e40c-426a-3557-08dc4ea63bb0/*")

Get podcast show information

Description

op3_show() obtains show-level information for a given podcast using OP3.

Usage

op3_show(show_id, episodes = FALSE)

Arguments

show_id

String representing an OP3 show UUID, podcast GUID, or a podcast RSS feed URL.

episodes

Boolean to return episode-level metadata along with the show-level information. Default is FALSE.

Value

tibble data frame with the following columns:

  • showUuid: Podcast OP3 UUID

  • title: Podcast title

  • podcastGuid: Podcast GUID

  • statsPageUrl: URL of the OP3 statistics web page for the podcast

  • episodes_id: Episode ID (when episodes is TRUE)

  • episodes_title: Episode title (when episodes is TRUE)

Examples

# Requires API token

op3_show(show_id = "bb28afcc-137e-5c66-b231-4ffad7979b44")

Detect if OP3 API token is defined

Description

Detect if OP3 API token is defined

Usage

op3_token_isset()

Value

boolean, TRUE if 'OP3_API_TOKEN' is defined in the current R session.


Get top apps by share of downloads

Description

op3_top_apps() obtains global shares of application downloads over the last thirty days categorized by application

Usage

op3_top_apps(device_name = NULL)

Arguments

device_name

Optional string of a specific device ID to constrain results.

Value

tibble data frame with the following columns:

  • app_name: Device name

  • value: Percentage of download share

  • min_date: Oldest date in data range

  • max_date: Newest date in data range

Examples

# Requires API token

op3_top_apps()

Get download numbers by application for a show

Description

op3_top_show_apps() obtains the download numbers for individual podcast applications over the last three calendar months for a specific show.

Usage

op3_top_show_apps(show_id)

Arguments

show_id

String representing an OP3 show UUID, podcast GUID, or a podcast RSS feed URL.

Value

tibble data frame with the following columns:

  • show_uuid: OP3 show UUID

  • app_name: Name of podcast application

  • value: Number of downloads in the last three calendar months

Examples

# Requires API token

op3_top_show_apps(show_id = "bb28afcc-137e-5c66-b231-4ffad7979b44")

Get recent episodes with transcripts

Description

op3_transcripts() obtains the most recent episodes of podcasts using OP3 containing transcripts along with their daily download numbers.

Usage

op3_transcripts(limit = 100, nest_downloads = TRUE)

Arguments

limit

Integer of maximum number of episodes to return. The maximum limit supported is 100.

nest_downloads

Boolean to create a list column of the daily download metrics or expand the data frame to have one row per day of download metrics. Default is TRUE.

Value

tibble data frame with the following columns:

  • asof: Timestamp

  • pubdate: Episode publish timestamp

  • podcastGuid: Podcast GUID

  • episodeItemGuid: Episode GUID

  • hasTranscripts: Boolean indicating if the episode has a transcript

  • dailyDownloads: List of episode download numbers by date (when nest_downloads is TRUE)

  • date: Date of download number (when nest_downloads is FALSE)

  • n_downloads: Number of downloads for the date (when nest_downloads is FALSE)

Examples

# Requires API token

op3_transcripts(limit = 5, nest_downloads = FALSE)