Query the Semantic Scholar Academic
Graph API for papers and return the results as an sm_corpus.
Supports both keyword search (query) and batch paper lookup
(paper_ids). Optionally fetches pre-computed SPECTER embeddings.
Usage
sm_fetch_semantic_scholar(
query = NULL,
paper_ids = NULL,
n_max = 100L,
api_key = Sys.getenv("SEMANTIC_SCHOLAR_API_KEY"),
include_embeddings = FALSE,
verbose = TRUE,
call = rlang::caller_env()
)Arguments
- query
Free-text search query. If
NULL,paper_idsmust be supplied.- paper_ids
Character vector of Semantic Scholar paper IDs, DOIs (prefixed
DOI:), arXiv IDs (prefixedARXIV:), or PMIDs (prefixedPMID:). IfNULL,querymust be supplied.- n_max
Maximum number of papers to return (default 100).
- api_key
Semantic Scholar API key. Read from
SEMANTIC_SCHOLAR_API_KEYenv var by default.- include_embeddings
Logical; if
TRUE, request SPECTER embeddings for each paper and attach as an embedding matrix.- verbose
Print progress messages?
- call
Caller environment for error reporting.
Examples
if (FALSE) { # \dontrun{
corpus <- sm_fetch_semantic_scholar(query = "bibliometrics", n_max = 10)
print(corpus)
} # }