knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

semanticscholar

Lifecycle: experimental R-CMD-check

The goal of semanticscholar is to offer data access to data from Semantic Scholar through their lightweight API which can provide data on publications and authors. Semantic Scholar is a free, non-profit academic search and discovery engine whose mission is to empower researchers.

Installation

You can install the current version of semanticscholar from GitHub with:

#install.packages("devtools")
devtools::install_github("kth-library/semanticscholar", dependencies = TRUE)

Example

This is a basic example which shows you how to get information for papers and authors:

library(semanticscholar)
library(dplyr)
suppressPackageStartupMessages(library(purrr))
library(knitr)

# get a paper using an identifier
paper <- S2_paper("arXiv:1705.10311", include_unknown_refs = TRUE)

# authors on that paper
authors <- paper$authors

# for one of the authors
author_ids <- authors$authorId
author <- S2_author(author_ids[1])

# get just paper count, citation count and hIndex for a specific author
countz <- S2_author2(author_ids[1], fields = "url,paperCount,citationCount,hIndex")
countz %>% dplyr::as_tibble()

# for a specific paper, get the TLDR;

S2_paper2(identifier = "649def34f8be52c8b66281af98ae884c09aef38b", fields="tldr")$tldr$text

# list some of the papers
papers <- 
  author$papers %>% 
  select(title, year)

papers %>% head(5) %>% knitr::kable()

# get data from several identifiers for importing into Zotero
ids <- c("10.1038/nrn3241", "CorpusID:37220927")
my_refs <- zotero_references(ids)

# this data can now be imported via the Zetero API using https://github.com/giocomai/zoteroR
# showing data form the first record
my_refs[[1]]$journalArticle %>% glimpse()
my_refs[[2]]$creators %>% knitr::kable()

Rate limits and endpoints

By default the rate limit allows 100 request per 5 minute period. This allows for making new requests every 3-4 seconds.

By requesting an API key from Semantic Scholar, this rate can be faster, such as 100 requests per second. If you want to use an API key provided by Semantic Scholar, then edit the ~/.Renviron file to add the key as a value for an environment variable SEMANTICSCHOLAR_API. This R package will then use API endpoints which are faster, with higher rate limits than the regular API endpoints.

The rate limit and API base URL endpoint can be verified:

S2_api()
S2_ratelimit()

Data source attribution

When data from semanticscholar is displayed publicly, this attribution also needs to be displayed:

r S2_attribution()



KTH-Library/semanticscholar documentation built on Feb. 2, 2025, 2:50 a.m.