st_metrics: Fetch Sensor Tower Metrics

View source: R/st_metrics.R

st_metricsR Documentation

Fetch Sensor Tower Metrics

Description

Thin v1.0.0 facade for sales/download metrics. The function validates a standardized argument set, dispatches to the legacy implementation that best matches the request, and then normalizes the result into a stable schema.

Usage

st_metrics(
  app_id,
  metrics = c("revenue", "downloads"),
  os = "unified",
  countries = "WW",
  date_from = Sys.Date() - 90,
  date_to = Sys.Date(),
  granularity = "daily",
  revenue_unit = c("dollars", "cents"),
  shape = c("long", "wide"),
  cache = TRUE,
  auth_token = NULL
)

Arguments

app_id

Character scalar or vector of app identifiers. Each entry can be a Sensor Tower unified app ID, an iOS numeric app ID, or an Android package name.

metrics

Character vector of metrics to return. Supported values are '"revenue"' and '"downloads"'.

os

Character scalar. One of '"ios"', '"android"', or '"unified"'.

countries

Character vector of 2-letter country codes. Use '"WW"' for worldwide aggregates.

date_from, date_to

Date bounds for the query. Accept 'Date' objects or ISO date strings.

granularity

Character scalar. One of '"daily"', '"weekly"', '"monthly"', or '"quarterly"'.

revenue_unit

Character scalar. '"dollars"' (default) returns revenue in base currency units. '"cents"' returns revenue in cents for compatibility with the legacy API surface.

shape

Character scalar. '"long"' returns one row per metric observation. '"wide"' returns one row per app/date/country with separate metric columns.

cache

Logical. If 'TRUE', use a process-local cache keyed on the normalized arguments.

auth_token

Optional Sensor Tower API token. If 'NULL', falls back to 'SENSORTOWER_AUTH_TOKEN'.

Value

If 'shape = "long"', a tibble with columns: - 'app_id': identifier supplied to 'st_metrics()' - 'os': normalized operating system - 'country': 2-letter country code - 'date': observation date - 'metric': one of '"revenue"' or '"downloads"' - 'value': metric value; revenue is in dollars by default and cents when 'revenue_unit = "cents"'

If 'shape = "wide"', a tibble with columns: - 'app_id' - 'os' - 'country' - 'date' - one numeric column per requested metric

Examples

## Not run: 
st_metrics(
  app_id = "553834731",
  os = "ios",
  countries = "US",
  date_from = Sys.Date() - 30,
  date_to = Sys.Date() - 1
)

st_metrics(
  app_id = c("553834731", "com.supercell.clashofclans"),
  os = "unified",
  shape = "wide",
  countries = c("US", "GB"),
  revenue_unit = "cents"
)

## End(Not run)


sensortowerR documentation built on May 14, 2026, 5:06 p.m.