Skip to contents

Look up DOIs in the corpus via the Altmetric API and add attention scores, Mendeley reader counts, and social media metrics to the works table.

This enricher is idempotent: re-running it updates existing Altmetric data rather than duplicating it.

Usage

sm_enrich_altmetric(
  corpus,
  api_key = Sys.getenv("ALTMETRIC_API_KEY"),
  verbose = TRUE,
  call = rlang::caller_env()
)

Arguments

corpus

An sm_corpus object.

api_key

Altmetric API key. Read from ALTMETRIC_API_KEY env var. The Altmetric Details Page API has required a key since November 2025; without one, no work is enriched and a warning says so.

verbose

Print progress messages?

call

Caller environment for error reporting.

Value

An sm_corpus object with added altmetric_score, mendeley_readers, twitter_count, and news_count columns in the works table, plus provenance rows for the works Altmetric answered for. Works whose lookup failed (other than "not found") keep missing values and are reported in a warning of class scimapR_altmetric_unchecked with their work_ids.

Examples

if (FALSE) { # \dontrun{
# Not run: the Altmetric API needs an API key (`ALTMETRIC_API_KEY`).
corpus <- sm_corpus(works = tibble::tibble(
  work_id = "W1",
  doi = "10.1371/journal.pbio.1002541"
))
corpus <- sm_enrich_altmetric(corpus)
} # }