OpenalexR
Getting bibliographic records from OpenAlex
Install / Use
/learn @ropensci/OpenalexRREADME
openalexR <img src="man/figures/logo.png" align="right" height="139"/>
<!-- badges: start --> <!-- badges: end -->openalexR helps you interface with the OpenAlex API to retrieve bibliographic information about publications, authors, institutions, sources, funders, publishers, topics and keywords with 5 main functions:
-
oa_fetch: composes three functions below so the user can execute everything in one step, i.e.,oa_query |> oa_request |> oa2df -
oa_query: generates a valid query, written following the OpenAlex API syntax, from a set of arguments provided by the user. -
oa_request: downloads a collection of entities matching the query created byoa_queryor manually written by the user, and returns a JSON object in a list format. -
oa2df: converts the JSON object in classical bibliographic tibble/data frame. -
oa_random: get random entity, e.g.,oa_random("works")gives a different work each time you run it
📜 Citation
If you use openalexR in research, please cite:
Aria, M., Le T., Cuccurullo, C., Belfiore, A. & Choe, J. (2024), openalexR: An R-Tool for Collecting Bibliometric Data from OpenAlex, The R Journal, 15(4), 167-180, DOI: https://doi.org/10.32614/RJ-2023-089.
🙌 Support OpenAlex
If OpenAlex has helped you, consider writing a Testimonial which will help support the OpenAlex team and show that their work is making a real and necessary impact.
⚙️ Setup
You can install the developer version of openalexR from GitHub with:
install.packages("remotes")
remotes::install_github("ropensci/openalexR")
You can install the released version of openalexR from CRAN with:
install.packages("openalexR")
🔑 API Key (Required)
As of February 13, 2025, the OpenAlex API requires an API key. Without a key, you are limited to 100 credits per day (for testing only). With a free API key, you get 100,000 credits per day.
See the OpenAlex API access documentation for details.
To get your API key:
- Create a free account at openalex.org
- Copy your API key from https://openalex.org/settings/api
To use your API key with openalexR, add it to your .Rprofile with
file.edit("~/.Rprofile"):
options(openalexR.apikey = "YOUR_API_KEY")
Alternatively, you can open .Renviron with file.edit("~/.Renviron")
and add:
openalexR.apikey = YOUR_API_KEY
library(openalexR)
library(dplyr)
library(ggplot2)
🌿 Examples
There are different
filters/arguments
you can use in oa_fetch, depending on which
entity you’re interested in: . We
show a few examples below.
📚 Works
Goal: Download all information about a givens set of publications (known DOIs).
Use doi as a works
filter:
works_from_dois <- oa_fetch(
entity = "works",
doi = c("10.1016/j.joi.2017.08.007", "https://doi.org/10.1007/s11192-013-1221-3"),
verbose = TRUE
)
#> Requesting url:
#> <https://api.openalex.org/works?filter=doi%3A10.1016%2Fj.joi.2017.08.007%7Chttps%3A%2F%2Fdoi.org%2F10.1007%2Fs11192-013-1221-3>
#> ℹ Getting 1 page of results with a total of 2 records...
We can view the output tibble/dataframe, works_from_dois,
interactively in RStudio or inspect it with base functions like str or
head. We also provide the experimental show_works function to
simplify the result (e.g., remove some columns, keep first/last author)
for easy viewing.
Note: the following table is wrapped in knitr::kable() to be
displayed nicely in this README, but you will most likely not need this
function.
# str(works_from_dois, max.level = 2)
# head(works_from_dois)
# show_works(works_from_dois)
works_from_dois |>
show_works() |>
knitr::kable()
| id | display_name | first_author | last_author | is_oa | top_concepts | |:---|:---|:---|:---|:---|:---| | W2755950973 | bibliometrix : An R-tool for comprehensive science mapping analysis | Massimo Aria | Corrado Cuccurullo | FALSE | Workflow, Bibliometrics, Software | | W2038196424 | Coverage and adoption of altmetrics sources in the bibliometric community | Stefanie Haustein | Jens Terliesner | FALSE | Altmetrics, Bookmarking, Social media |
Goal: Download all works given their PMIDs.
Use pmid as a filter:
works_from_pmids <- oa_fetch(
entity = "works",
pmid = c("14907713", 32572199),
verbose = TRUE
)
#> Requesting url:
#> <https://api.openalex.org/works?filter=pmid%3A14907713%7C32572199>
#> ℹ Getting 1 page of results with a total of 2 records...
works_from_pmids |>
show_works() |>
knitr::kable()
| id | display_name | first_author | last_author | is_oa | top_concepts | |:---|:---|:---|:---|:---|:---| | W1775749144 | PROTEIN MEASUREMENT WITH THE FOLIN PHENOL REAGENT | OliverH. Lowry | RoseJ. Randall | TRUE | Reagent, Phenol | | W3036882247 | Integrating spatial gene expression and breast tumour morphology via deep learning | Bryan He | James Zou | FALSE | Histopathology, Gene, Cancer |
Goal: Download all works published by a set of authors (known ORCIDs).
Use author.orcid as a filter (either canonical form with
https://orcid.org/ or without will work):
works_from_orcids <- oa_fetch(
entity = "works",
author.orcid = c("0000-0001-6187-6610", "0000-0002-8517-9411"),
verbose = TRUE
)
#> Requesting url:
#> <https://api.openalex.org/works?filter=author.orcid%3A0000-0001-6187-6610%7C0000-0002-8517-9411>
#> ℹ Getting 2 pages of results with a total of 287 records...
works_from_orcids |>
show_works() |>
knitr::kable()
| id | display_name | first_author | last_author | is_oa | top_concepts | |:---|:---|:---|:---|:---|:---| | W2755950973 | bibliometrix : An R-tool for comprehensive science mapping analysis | Massimo Aria | Corrado Cuccurullo | FALSE | Workflow, Bibliometrics, Software | | W2741809807 | The state of OA: a large-scale analysis of the prevalence and impact of Open Access articles | Heather Piwowar | Stefanie Haustein | TRUE | Citation, License, Bibliometrics | | W3005144120 | Mapping the Evolution of Social Research and Data Science on 30 Years of Social Indicators Research | Massimo Aria | Maria Spano | FALSE | Human geography, Data collection, Position (finance) | | W2122130843 | Scientometrics 2.0: New metrics of scholarly impact on the social Web | Jason Priem | Bradely H. Hemminger | TRUE | Bookmarking, Altmetrics, Social media | | W2408216567 | Foundations and trends in performance management. A twenty-five years bibliometric analysis in business and public administration domains | Corrado Cuccurullo | Fabrizia Sarto | FALSE | Domain (mathematical analysis), Content analysis, Public domain | | W2396414759 | The Altmetrics Collection | Jason Priem | Dario Taraborelli | TRUE | Social media, Citation, Altmetrics |
Goal: Download all works that have been cited more than 50 times, published between 2020 and 2021, and include the strings “bibliometric analysis” or “science mapping” in the title. Maybe we also want the results to be sorted by total citations in a descending order.
works_search <- oa_fetch(
entity = "works",
title.search = c("bibliometric analysis", "science mapping"),
cited_by_count = ">50",
from_publication_date = "2020-01-01",
to_publication_date = "2021-12-31",
options = list(sort = "cited_by_count:desc"),
verbose = TRUE
)
#> Requesting url:
#> <https://api.openalex.org/works?filter=title.search%3Abibliometric%20analysis%7Cscience%20mapping%2Ccited_by_count%3A%3E50%2Cfrom_publication_date%3A2020-01-01%2Cto_publication_date%3A2021-12-31&sort=cited_by_count%3Adesc>
#> ℹ Getting 3 pages of results with a total of 561 records...
#> ⠙ OpenAlex downloading [2/3] ■■■■■■■■■■■■■■■■■■■■■ 67% ETA: 1s
#> ⠙ OpenAlex downloading [3/3] ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100% ETA: 0s
#>
#>
#> ⠙ Converting [259/561] ■■■■■■■■■■■■■■■ 46% ETA: 1s
#> ⠹ Converting [513/561] ■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 91% ETA: 0s
#> ⠸ Converting [554/561] ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 99% ETA: 0s
#> ⠸ Converting [561/561] ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100% ETA: 0s
works_search |>
show_works() |>
knitr::kable()
| id | display_name | first_author | last_author | is_oa | top_concepts | |:---|:---|:---|:---|:---|:---| | W3160856016 | How to conduct a bibliometric analysis: An overview and guidelines | Naveen Donthu | Weng Marc Lim | FALSE | Bibliometrics, Field (mathematics), Resource (disambiguation) | | W3001491100 | Software tools for conducting bibliometric analysis in science: An up-to-date review | José A. Moral-Muñoz | Manuel J. Cobo | TRUE | Bibliometrics, Visualization, Set (abstract data type) | | W3038273726 | Investigating the emerging COVID-19 res
