A Brief Introduction to openalexR

 

https://github.com/massimoaria/openalexR

Latest version: 0.0.1, 2022-04-20

 

by Massimo Aria

Full Professor in Social Statistics

PhD in Computational Statistics

Laboratory and Research Group STAD Statistics, Technology, Data Analysis

Department of Economics and Statistics

University of Naples Federico II

email aria@unina.it

https://massimoaria.com

 

An R-package to gather bibliographic data from OpenAlex.

Introduction

 

The goal of openalexR is to gather bibliographic metadata about publications, authors, venues, institutions and concepts from OpenAlex using API.

OpenAlex is a fully open catalog of the global research system. It’s named after the ancient Library of Alexandria. The OpenAlex dataset describes scholarly entities and how those entities are connected to each other. There are five types of entities:

(source: OpenAlex website)

Installation

You can install the developer version of the openalexR from GitHub with:

install.packages("devtools")
devtools::install_github("massimoaria/openalexR")

You can install the released version of openalexR from CRAN with:

install.packages("openalexR")

 

 

Package loading

   library(openalexR)

 

 

openalexR overview

The basic idea of openalexR is to provide three main functions helping the user to:

 

OpenAlex defined a custom query language based on entity type. You can choose to write a valid query using that language or, in alternative, using the function oaQueryBuild.

oaQueryBuild generates a valid query, written following the OpenAlex API language, from a set of arguments provided by the user.

The function oaApiRequest downloads a collection of entities matching the query created by oaQueryBuild or manually written by the user. The function will return a JSON object in a list format.

The function oa2df converts the JSON object in classical bibliographic data frame.

Finally, the function oa2bibliometrix converts an OpenAlex data frame into a bibliometrix object

 

Get full records through entity IDs.

 

Query to obtain all information about a single publications

The following paper:

Aria, M., & Cuccurullo, C. (2017). bibliometrix: An R-tool for comprehensive science mapping analysis. Journal of informetrics, 11(4), 959-975.

is associated to the OpenAlex-id W2755950973.

The function oaQueryBuild supports the query creation by providing a set of arguments.

In this example, we need to pass a single argument to the function, that is, the identifier of the entity to download: identifier = “W2755950973”.

query_work <- oaQueryBuild(
  identifier = "W2755950973",
  entity = "works"
  )

cat(query_work)
## https://api.openalex.org/works/W2755950973

As results, oaQueryBuild returns the query string including the OpenAlex endpoint API server address. You should change it by using the argument “endpoint = address

The function oaApiRequest downloads the bibliographic records matching the query.

 res <- oaApiRequest(
    query_url = query_work
    )
df <- oa2df(res, entity = "works")

dplyr::glimpse(df)
## Rows: 1
## Columns: 25
## $ id            <chr> "https://openalex.org/W2755950973"
## $ TI            <chr> "bibliometrix: An R-tool for comprehensive science mappi…
## $ author        <list> [<data.frame[2 x 10]>]
## $ AB            <chr> "Abstract The use of bibliometrics is gradually extendin…
## $ pubdata       <chr> "2017-11-01"
## $ SO            <chr> "Journal of Informetrics"
## $ SO_ID         <chr> "https://openalex.org/V205292342"
## $ PU            <chr> "Elsevier"
## $ IS            <list> <"1875-5879", "1751-1577">
## $ URL           <chr> "https://doi.org/10.1016/j.joi.2017.08.007"
## $ first_page    <chr> "959"
## $ last_page     <chr> "975"
## $ volume        <chr> "11"
## $ issue         <chr> "4"
## $ OA            <lgl> FALSE
## $ TC            <int> 1180
## $ TCperYear     <list> [<data.frame[6 x 2]>]
## $ PY            <int> 2017
## $ cited_by_url  <chr> "https://api.openalex.org/works?filter=cites:W2755950973"
## $ ids           <list> [[<data.frame[3 x 2]>]]
## $ DI            <chr> "https://doi.org/10.1016/j.joi.2017.08.007"
## $ DT            <chr> "journal-article"
## $ CR            <list> <"https://openalex.org/W2065892499", "https://openalex.…
## $ related_works <list> <"https://openalex.org/W2408216567", "https://openalex.o…
## $ concept       <list> [<data.frame[4 x 5]>]

 

Query to obtain all information about a single publications using external id formats

OpenAlex endpoint accepts an OpenAlex ID, but many external IDs (eg DOI, ISSN) are accepted as well, in several formats.

DOI (Digital Object Identifier)

We can get a publication record through its DOI using the format doi:doi identifier. Example:

query_work <- oaQueryBuild(
  identifier = "doi:10.1016/j.joi.2017.08.007",
  entity = "works"
  )

cat(query_work)
## https://api.openalex.org/works/doi:10.1016/j.joi.2017.08.007
 res <- oaApiRequest(
    query_url = query_work
    )
df <- oa2df(res, entity = "works")

dplyr::glimpse(df)
## Rows: 1
## Columns: 25
## $ id            <chr> "https://openalex.org/W2755950973"
## $ TI            <chr> "bibliometrix: An R-tool for comprehensive science mappi…
## $ author        <list> [<data.frame[2 x 10]>]
## $ AB            <chr> "Abstract The use of bibliometrics is gradually extendin…
## $ pubdata       <chr> "2017-11-01"
## $ SO            <chr> "Journal of Informetrics"
## $ SO_ID         <chr> "https://openalex.org/V205292342"
## $ PU            <chr> "Elsevier"
## $ IS            <list> <"1875-5879", "1751-1577">
## $ URL           <chr> "https://doi.org/10.1016/j.joi.2017.08.007"
## $ first_page    <chr> "959"
## $ last_page     <chr> "975"
## $ volume        <chr> "11"
## $ issue         <chr> "4"
## $ OA            <lgl> FALSE
## $ TC            <int> 1180
## $ TCperYear     <list> [<data.frame[6 x 2]>]
## $ PY            <int> 2017
## $ cited_by_url  <chr> "https://api.openalex.org/works?filter=cites:W2755950973"
## $ ids           <list> [[<data.frame[3 x 2]>]]
## $ DI            <chr> "https://doi.org/10.1016/j.joi.2017.08.007"
## $ DT            <chr> "journal-article"
## $ CR            <list> <"https://openalex.org/W2065892499", "https://openalex.…
## $ related_works <list> <"https://openalex.org/W2408216567", "https://openalex.o…
## $ concept       <list> [<data.frame[4 x 5]>]

Persistent Identifiers (PIDs)

Many persistent identifiers (PIDs) are canonically expressed as a URL that will take you to the thing being identified. Where these URL formats exist, OpenAlex treats them as the canonical ID, and also accepts them as valid IDs. Example:

query_work <- oaQueryBuild(
  identifier = "doi:https://doi.org/10.1016/j.joi.2017.08.007",
  entity = "works"
  )

cat(query_work)
## https://api.openalex.org/works/doi:https://doi.org/10.1016/j.joi.2017.08.007
 res <- oaApiRequest(
    query_url = query_work
    )
df <- oa2df(res, entity = "works")

dplyr::glimpse(df)
## Rows: 1
## Columns: 25
## $ id            <chr> "https://openalex.org/W2755950973"
## $ TI            <chr> "bibliometrix: An R-tool for comprehensive science mappi…
## $ author        <list> [<data.frame[2 x 10]>]
## $ AB            <chr> "Abstract The use of bibliometrics is gradually extendin…
## $ pubdata       <chr> "2017-11-01"
## $ SO            <chr> "Journal of Informetrics"
## $ SO_ID         <chr> "https://openalex.org/V205292342"
## $ PU            <chr> "Elsevier"
## $ IS            <list> <"1875-5879", "1751-1577">
## $ URL           <chr> "https://doi.org/10.1016/j.joi.2017.08.007"
## $ first_page    <chr> "959"
## $ last_page     <chr> "975"
## $ volume        <chr> "11"
## $ issue         <chr> "4"
## $ OA            <lgl> FALSE
## $ TC            <int> 1180
## $ TCperYear     <list> [<data.frame[6 x 2]>]
## $ PY            <int> 2017
## $ cited_by_url  <chr> "https://api.openalex.org/works?filter=cites:W2755950973"
## $ ids           <list> [[<data.frame[3 x 2]>]]
## $ DI            <chr> "https://doi.org/10.1016/j.joi.2017.08.007"
## $ DT            <chr> "journal-article"
## $ CR            <list> <"https://openalex.org/W2065892499", "https://openalex.…
## $ related_works <list> <"https://openalex.org/W2408216567", "https://openalex.o…
## $ concept       <list> [<data.frame[4 x 5]>]

Query to obtain all information about a two o more publications

To download the records of two o more identifiers through a single query, we can recursively apply oaApiRequest to each id using the function lapply.

ids <- c("W2755950973","W3005144120")

res <- lapply(ids, function(x){
  oaApiRequest(
    query_url = oaQueryBuild(
      identifier = x,
      entity = "works"
    )
  )
})
df <- oa2df(res, entity = "works")

dplyr::glimpse(df)
## Rows: 2
## Columns: 25
## $ id            <chr> "https://openalex.org/W2755950973", "https://openalex.or…
## $ TI            <chr> "bibliometrix: An R-tool for comprehensive science mappi…
## $ author        <list> [<data.frame[2 x 10]>], [<data.frame[3 x 10]>]
## $ AB            <chr> "Abstract The use of bibliometrics is gradually extendi…
## $ pubdata       <chr> "2017-11-01", "2020-06-01"
## $ SO            <chr> "Journal of Informetrics", "Social Indicators Research"
## $ SO_ID         <chr> "https://openalex.org/V205292342", "https://openalex.org…
## $ PU            <chr> "Elsevier", "Springer Nature"
## $ IS            <list> <"1875-5879", "1751-1577">, <"1573-0921", "0303-8300">
## $ URL           <chr> "https://doi.org/10.1016/j.joi.2017.08.007", "https://do…
## $ first_page    <chr> "959", "803"
## $ last_page     <chr> "975", "831"
## $ volume        <chr> "11", "149"
## $ issue         <chr> "4", "3"
## $ OA            <lgl> FALSE, FALSE
## $ TC            <int> 1180, 33
## $ TCperYear     <list> [<data.frame[6 x 2]>], [<data.frame[3 x 2]>]
## $ PY            <int> 2017, 2020
## $ cited_by_url  <chr> "https://api.openalex.org/works?filter=cites:W2755950973…
## $ ids           <list> [[<data.frame[3 x 2]>]], [[<data.frame[3 x 2]>]]
## $ DI            <chr> "https://doi.org/10.1016/j.joi.2017.08.007", "https://do…
## $ DT            <chr> "journal-article", "journal-article"
## $ CR            <list> <"https://openalex.org/W2065892499", "https://openalex.o…
## $ related_works <list> <"https://openalex.org/W2408216567", "https://openalex.…
## $ concept       <list> [<data.frame[4 x 5]>], [<data.frame[8 x 5]>]

Query to obtain all information about a single author

The author Massimo Aria is associated to the OpenAlex-id A923435168.

query_author <- oaQueryBuild(
  identifier = "A923435168",
  entity = "authors")

cat(query_author)
## https://api.openalex.org/authors/A923435168
 res_author <- oaApiRequest(
    query_url = query_author,
    total.count = FALSE,
    verbose = FALSE
 )
df <- oa2df(res_author, entity = "authors")

dplyr::glimpse(df)
## Rows: 1
## Columns: 15
## $ id                  <chr> "https://openalex.org/A923435168"
## $ name                <chr> "Massimo Aria"
## $ name_alternatives   <lgl> NA
## $ ids                 <list> [<data.frame[4 x 2]>]
## $ orcid               <chr> "https://orcid.org/0000-0002-8517-9411"
## $ works_count         <int> 102
## $ TC                  <int> 2613
## $ TCperYear           <list> [<data.frame[11 x 3]>]
## $ affiliation_name    <chr> "University of Naples Federico II"
## $ affiliation_id      <chr> "https://openalex.org/I71267560"
## $ affiliation_ror     <chr> "https://ror.org/05290cv24"
## $ affiliation_country <chr> "IT"
## $ affiliation_type    <chr> "education"
## $ concept             <list> [<data.frame[11 x 5]>]
## $ works_api_url       <chr> "https://api.openalex.org/works?filter=author.id:A…

 

 

Get all entities matching a set of inclusion/exclusion criteria (filters)

In most cases, we are interested in downloading a collection of items that meet one or more inclusion/exclusion criteria (filters).

In this case, the query definition will not be based on a single identifier but the choice of the entity type (usually “works”, but also “authors”, “venues”, etc.) and one or more filters about this entity.

Filters narrow the list down to just entities that meet a particular condition–specifically, a particular value for a particular attribute. Supported attributes for each endpoints are listed on OpenAlex API Documentation Website.

Filters are formatted thusly: attribute:value. You set them using the ?filter query parameter. Filters are case-insensitive.

 

Each endpoint supports its own list of filters. Here they are, by endpoint:

 

/works filters

You can filter using these attributes of the Works object.

etc.

You can find more documentation about each attribute on the OA Documentation Work page.

 

/authors filters

You can filter using these attributes of the Authors object.

etc.

You can find more documentation about each attribute on the OA Documentation Author page.

 

/venues filters

You can filter using these attributes of the Venue object.

etc.

You can find more documentation about each attribute on the OA Documentation Venue page.

 

/institutions filters

You can filter using these attributes of the Institution object.

You can find more documentation about each attribute on the OA Documentation Institution page.

 

/concepts filters

You can filter using these attributes of the Concept object. You can find more documentation about each attribute on the Concept page.

You can find more documentation about each attribute on the OA Documentation Concept page.

 

Below we show some examples of filters in use.

 

Filters based on string matching

We want to download all works, cited more than 50 times, published between 2020 and 2021, which include the strings “bibliometric analysis” or “science mapping” in the title.

 

To do that, we have to set filters about three attributes: title content (“title.search”), starting date for publication (“from_publication_date”), and ending date for publication (“to_publication_date”).

Starting and ending dates can be passed to the function oaQueryBuild using the arguments date_from and date_to. The format is YYYY-MM-DD.

The other attributes can be passed to the function through the argument filter.

When an attribute has more than one item, these can be separated by the boolean operator OR represented by the symbol | .

On the contrary, different attributes have to be separated by commas.

e.g. filter = ‘title.search:“bibliometric analysis”|“science mapping”, cited_by_count:>50’

where:

  • ‘title.search:“bibliometric analysis”|“science mapping’

means all works containing the string “bibliometric analysis” OR “science mapping” in the publication title.

and:

  • cited_by_count:>100

means all works cited more than 100 times.

The whole filter ‘title.search:“bibliometric analysis”|“science mapping”,cited_by_count:>100’

can be read as:

*"all works containing the string "bibliometric analysis" OR "science mapping" in the publication title AND cited more than 50 times"*.
query <- oaQueryBuild(
    identifier=NULL,
    entity = "works",
    filter = 'title.search:"bibliometric analysis"|"science mapping",cited_by_count:>100',
    date_from = "2000-01-01",
    date_to = "2021-12-31",
    search=NULL,
    sort="cited_by_count:desc",
    endpoint = "https://api.openalex.org/")

The sort argument indicates how results have to be sorted.

In this example results are sorted by total citations in a descending order.

Setting the argument total.count=TRUE, the function oaApiRequest returns the number of items matching the query without downloading the collection.

 res <- oaApiRequest(
    query_url = query,
    total.count = TRUE,
    verbose = FALSE
    )

res$count
## [1] 74

Then, we can download the collection:

 res <- oaApiRequest(
    query_url = query,
    total.count = FALSE,
    verbose = FALSE
    )

and transform it into a data frame:

df <- oa2df(res, entity = "works")
dplyr::glimpse(df)
## Rows: 74
## Columns: 25
## $ id            <chr> "https://openalex.org/W2755950973", "https://openalex.or…
## $ TI            <chr> "bibliometrix: An R-tool for comprehensive science mappi…
## $ author        <list> [<data.frame[2 x 10]>], [<data.frame[4 x 10]>], [<data.…
## $ AB            <chr> "Abstract The use of bibliometrics is gradually extendin…
## $ pubdata       <chr> "2017-11-01", "2011-07-01", "2015-04-01", "2005-09-01", …
## $ SO            <chr> "Journal of Informetrics", "Journal of the Association f…
## $ SO_ID         <chr> "https://openalex.org/V205292342", "https://openalex.org…
## $ PU            <chr> "Elsevier", "Wiley", "Elsevier", "SAGE", "Wiley", "Sprin…
## $ IS            <list> <"1875-5879", "1751-1577">, <"1532-2882", "1532-2890">,…
## $ URL           <chr> "https://doi.org/10.1016/j.joi.2017.08.007", "https://do…
## $ first_page    <chr> "959", "1382", "101", "283", "2215", "1809", "1609", "1"…
## $ last_page     <chr> "975", "1402", "114", "317", "2222", "1831", "1630", "40…
## $ volume        <chr> "11", "62", "162", "44", "66", "105", "63", "2", "27", "…
## $ issue         <chr> "4", "7", NA, "3", "11", "3", "8", "2", "5", "1", "4", N…
## $ OA            <lgl> FALSE, FALSE, FALSE, NA, TRUE, TRUE, FALSE, TRUE, FALSE,…
## $ TC            <int> 1180, 849, 725, 671, 659, 426, 382, 329, 314, 306, 304, …
## $ TCperYear     <list> [<data.frame[6 x 2]>], [<data.frame[11 x 2]>], [<data.f…
## $ PY            <int> 2017, 2011, 2015, 2005, 2015, 2015, 2012, 2017, 2007, 20…
## $ cited_by_url  <chr> "https://api.openalex.org/works?filter=cites:W2755950973…
## $ ids           <list> [[<data.frame[3 x 2]>]], [[<data.frame[3 x 2]>]], [[<da…
## $ DI            <chr> "https://doi.org/10.1016/j.joi.2017.08.007", "https://do…
## $ DT            <chr> "journal-article", "journal-article", "journal-article",…
## $ CR            <list> <"https://openalex.org/W2065892499", "https://openalex.…
## $ related_works <list> <"https://openalex.org/W2408216567", "https://openalex.…
## $ concept       <list> [<data.frame[4 x 5]>], [<data.frame[4 x 5]>], [<data.fr…

 

Get all works citing a particular work.

We can download all publications citing another publication by using the filter attribute cites:id.

For example, if we want to download all publications citing the article Aria and Cuccurullo (2017) during the first quarter of 2022, we have to set the arguments filter, date_from, and date_to as:

filter = “cites:W2755950973”

date_from = “2022-01-01”

date_to = “2022-03-31”

where “W2755950973” is the OA id for the article by Aria and Cuccurullo (2017).

query1 <- oaQueryBuild(
 identifier=NULL,
 entity = "works",
 filter = "cites:W2755950973",
 date_from = "2022-01-01",
 date_to = "2022-03-31",
 sort=NULL)

res1 <- oaApiRequest(
    query_url = query1,
    total.count = TRUE,
    verbose = FALSE
    )

This query will return a collection of:

cat(res1$count, "publications")
## 166 publications

Let’s to download it:

res1 <- oaApiRequest(
    query_url = query1,
    total.count = FALSE,
    verbose = FALSE
    )

And then to convert it into a data frame:

df <- oa2df(res1, entity = "works")
dplyr::glimpse(df)
## Rows: 166
## Columns: 25
## $ id            <chr> "https://openalex.org/W4220662981", "https://openalex.or…
## $ TI            <chr> "Bibliometric Analysis of Multi-Level Perspective on Sus…
## $ author        <list> [<data.frame[5 x 10]>], [<data.frame[3 x 10]>], [<data.…
## $ AB            <chr> "The multi-level perspective (MLP) is a prominent framew…
## $ pubdata       <chr> "2022-03-31", "2022-03-31", "2022-03-31", "2022-03-29", …
## $ SO            <chr> "Sustainability", "European Journal of Innovation Manage…
## $ SO_ID         <chr> "https://openalex.org/V10134376", "https://openalex.org/…
## $ PU            <chr> "MDPI AG", "Emerald (MCB UP)", "MDPI AG", "Emerald (MCB …
## $ IS            <list> "2071-1050", <"1460-1060", "1758-7115">, <"1661-7827", …
## $ URL           <chr> "https://doi.org/10.3390/su14074145", "https://doi.org/1…
## $ first_page    <chr> "4145", NA, "4165", NA, NA, "1073", "1082", NA, NA, NA, …
## $ last_page     <chr> "4145", NA, "4165", NA, NA, "1073", "1082", NA, NA, NA, …
## $ volume        <chr> "14", NA, "19", NA, "9", "14", "14", NA, NA, NA, "14", "…
## $ issue         <chr> "7", NA, "7", NA, NA, "7", "7", NA, NA, NA, "7", "4", NA…
## $ OA            <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, …
## $ TC            <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ TCperYear     <list> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ PY            <int> 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 20…
## $ cited_by_url  <chr> "https://api.openalex.org/works?filter=cites:W4220662981…
## $ ids           <list> [[<data.frame[2 x 2]>]], [[<data.frame[2 x 2]>]], [[<da…
## $ DI            <chr> "https://doi.org/10.3390/su14074145", "https://doi.org/1…
## $ DT            <chr> "journal-article", "journal-article", "journal-article",…
## $ CR            <list> <"https://openalex.org/W1902979073", "https://openalex.…
## $ related_works <list> <"https://openalex.org/W2578464", "https://openalex.org…
## $ concept       <list> <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>,…

 

Get all authors matching a set of filters

We want download all authors’ records of scholars who work at the University of Naples Federico II (OpenAlex ID: I71267560) and who have published more than 499 works:

query_author <- oaQueryBuild(
  identifier = NULL,
  entity = "authors",
  filter = "last_known_institution.id:I71267560,works_count:>499")

We check how many records match the query:

res <- oaApiRequest(query_url = query_author,
                    total.count = TRUE,
                    verbose=FALSE)
res$count
## [1] 34

Then we download and convert the collection:

res <- oaApiRequest(query_url = query_author,
                    total.count = FALSE,
                    verbose=FALSE)
df <- oa2df(res, entity = "authors")

dplyr::glimpse(df)
## Rows: 34
## Columns: 15
## $ id                  <chr> "https://openalex.org/A2061787601", "https://opena…
## $ name                <chr> "Luca Lista", "Crisostomo Sciacca", "Alberto Alois…
## $ name_alternatives   <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ ids                 <list> [<data.frame[3 x 2]>], [<data.frame[3 x 2]>], [<d…
## $ orcid               <chr> "https://orcid.org/0000-0001-6471-5492", "https://…
## $ works_count         <int> 2538, 2231, 1506, 1165, 1119, 1058, 1025, 995, 965…
## $ TC                  <int> 98229, 61137, 77280, 66456, 46373, 34778, 27289, 3…
## $ TCperYear           <list> [<data.frame[11 x 3]>], [<data.frame[11 x 3]>], […
## $ affiliation_name    <chr> "University of Naples Federico II", "University of…
## $ affiliation_id      <chr> "https://openalex.org/I71267560", "https://openale…
## $ affiliation_ror     <chr> "https://ror.org/05290cv24", "https://ror.org/0529…
## $ affiliation_country <chr> "IT", "IT", "IT", "IT", "IT", "IT", "IT", "IT", "I…
## $ affiliation_type    <chr> "education", "education", "education", "education"…
## $ concept             <list> [<data.frame[25 x 5]>], [<data.frame[20 x 5]>], […
## $ works_api_url       <chr> "https://api.openalex.org/works?filter=author.id:A…

 

Get all institutions matching a set of filters

We want download all records regarding Italian institutions (country_code:it) that are classified as educational (type:education):

query_inst <- oaQueryBuild(
  entity = "institutions",
  filter = "country_code:it,type:education")

We check how many records match the query:

res <- oaApiRequest(query_url = query_inst,
                    total.count = TRUE,
                    verbose=TRUE)
## Requesting url: https://api.openalex.org/institutions?filter=country_code%3Ait%2Ctype%3Aeducation&per-page=200
res$count
## [1] 231

Then we download and convert the collection:

res <- oaApiRequest(query_url = query_inst,
                    total.count = FALSE,
                    verbose=TRUE)
## Requesting url: https://api.openalex.org/institutions?filter=country_code%3Ait%2Ctype%3Aeducation&per-page=200
## About to get a total of 2 pages of results with a total of 231 records.
df <- oa2df(res, entity = "institutions")

dplyr::glimpse(df)
## Rows: 231
## Columns: 19
## $ id                 <chr> "https://openalex.org/I861853513", "https://openale…
## $ name               <chr> "Sapienza University of Rome", "University of Milan…
## $ name_alternatives  <list> "Università degli Studi di Roma \"La Sapienza\"", …
## $ name_acronyms      <list> NA, "UNIMI", "UNIBO", "UNIPD", NA, "UNITO", "UniPi…
## $ name_international <list> [<data.frame[1 x 84]>], [<data.frame[1 x 59]>], [<…
## $ ror                <chr> "https://ror.org/02be6w209", "https://ror.org/00wjc…
## $ ids                <list> [<data.frame[6 x 2]>], [<data.frame[6 x 2]>], [<da…
## $ country            <chr> "IT", "IT", "IT", "IT", "IT", "IT", "IT", "IT", "IT…
## $ geo                <list> [<data.frame[1 x 7]>], [<data.frame[1 x 7]>], [<da…
## $ type               <chr> "education", "education", "education", "education",…
## $ homepage           <chr> "http://www.uniroma1.it/", "http://www.unimi.it/ENG…
## $ image              <chr> "https://upload.wikimedia.org/wikipedia/en/4/45/Sap…
## $ thumbnail          <chr> "https://upload.wikimedia.org/wikipedia/en/thumb/4/…
## $ associated_inst    <list> [<data.frame[1 x 24]>], [<data.frame[1 x 12]>], [<…
## $ works_count        <int> 171175, 156354, 127512, 124963, 87765, 87187, 79087…
## $ TC                 <int> 12417861, 12196097, 10647850, 10229005, 6125697, 72…
## $ TCperYear          <list> [<data.frame[11 x 3]>], [<data.frame[11 x 3]>], [<…
## $ concept            <list> [<data.frame[13 x 5]>], [<data.frame[10 x 5]>], [<…
## $ works_api_url      <chr> "https://api.openalex.org/works?filter=institutions…

 

Get all venues matching a set of filters

We want download all records regarding journals that have published more than 100,000 works:

query_venue <- oaQueryBuild(
  entity = "venues",
  filter = "works_count:>100000")

We check how many records match the query:

res <- oaApiRequest(query_url = query_venue,
                    total.count = TRUE,
                    verbose=TRUE)
## Requesting url: https://api.openalex.org/venues?filter=works_count%3A%3E100000&per-page=200
res$count
## [1] 41

Then we download and convert the collection:

res <- oaApiRequest(query_url = query_venue,
                    total.count = FALSE,
                    verbose=TRUE)
## Requesting url: https://api.openalex.org/venues?filter=works_count%3A%3E100000&per-page=200
## About to get a total of 1 pages of results with a total of 41 records.
df <- oa2df(res, entity="venues")

dplyr::glimpse(df)
## Rows: 41
## Columns: 14
## $ id            <chr> "https://openalex.org/V2751751161", "https://openalex.or…
## $ name          <chr> "Social Science Research Network", "Research Papers in E…
## $ publisher     <chr> NA, NA, "Wiley", NA, "BMJ", "Public Library of Science",…
## $ issn          <list> NA, NA, <"1431-5890", "0931-7597", "1522-2667">, <"1611…
## $ issn_l        <list> NA, NA, "0931-7597", "0302-9743", "0959-8138", "1932-62…
## $ is_oa         <lgl> NA, NA, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, NA, FAL…
## $ is_in_doaj    <lgl> NA, NA, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, NA, FAL…
## $ ids           <list> [<data.frame[2 x 2]>], [<data.frame[2 x 2]>], [<data.fr…
## $ homepage      <chr> "http://www.ssrn.com/", "http://www.repec.org/", NA, "ht…
## $ works_count   <int> 876560, 791035, 728300, 493532, 301955, 282522, 272575, …
## $ TC            <int> 3236982, 2932956, 252130, 5742566, 3517969, 6594797, 190…
## $ TCperYear     <list> [<data.frame[11 x 3]>], [<data.frame[11 x 3]>], [<data.…
## $ concept       <list> [<data.frame[10 x 5]>], [<data.frame[11 x 5]>], [<data.…
## $ works_api_url <chr> "https://api.openalex.org/works?filter=host_venue.id:V27…

 

Get all concepts matching a set of filters

We want to download the records of all the concepts that concern at least one million works:

query_concept <- oaQueryBuild(
  entity = "concepts",
  filter = "works_count:>1000000")

We check how many records match the query:

res <- oaApiRequest(query_url = query_concept,
                    total.count = TRUE,
                    verbose=TRUE)
## Requesting url: https://api.openalex.org/concepts?filter=works_count%3A%3E1000000&per-page=200
res$count
## [1] 113

Then we download and convert the collection:

res <- oaApiRequest(query_url = query_concept,
                    total.count = FALSE,
                    verbose=TRUE)
## Requesting url: https://api.openalex.org/concepts?filter=works_count%3A%3E1000000&per-page=200
## About to get a total of 1 pages of results with a total of 113 records.
df <- oa2df(res, entity="concepts")

dplyr::glimpse(df)
## Rows: 113
## Columns: 16
## $ id                        <chr> "https://openalex.org/C71924100", "https://o…
## $ name                      <chr> "Medicine", "Computer science", "Chemistry",…
## $ name_international        <list> [<data.frame[1 x 193]>], [<data.frame[1 x 1…
## $ description               <chr> "field of study for diagnosing, treating and…
## $ description_international <list> [<data.frame[1 x 44]>], [<data.frame[1 x 38…
## $ wikidata                  <chr> "https://www.wikidata.org/wiki/Q11190", "htt…
## $ level                     <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0,…
## $ ids                       <list> [<data.frame[5 x 2]>], [<data.frame[5 x 2]>…
## $ image                     <chr> "https://upload.wikimedia.org/wikipedia/comm…
## $ thumbnail                 <chr> "https://upload.wikimedia.org/wikipedia/comm…
## $ ancestors                 <list> NA, NA, NA, NA, NA, NA, NA, NA, NA, [<data.…
## $ rel_concepts              <list> [<data.frame[51 x 5]>], [<data.frame[93 x 5…
## $ works_count               <int> 38700520, 27478212, 20964374, 18895013, 1845…
## $ TC                        <int> 428237996, 231013792, 361737994, 49760576, 2…
## $ TCperYear                 <list> [<data.frame[11 x 3]>], [<data.frame[11 x 3…
## $ works_api_url             <chr> "https://api.openalex.org/works?filter=conce…

Convert an OpenAlex data frame to a bibliometrix object

The bibliometrix R-package (https://www.bibliometrix.org) provides a set of tools for quantitative research in bibliometrics and scientometrics. It is written in the R language, which is an open-source environment and ecosystem.

Today it represents one of the most used science mapping software in the world. In a recent survey on bibliometric analysis tools, Moral-Muñoz et al. (2020) wrote: “At this moment, maybe Bibliometrix and its Shiny platform contain the more extensive set of techniques implemented, and together with the easiness of its interface, could be a great software for practitioners”.

The function oa2bibliometrix converts a bibliographic data frame of works into a bibliometrix object. This object can be used as input collection of a science mapping workflow.

query1 <- oaQueryBuild(
 identifier=NULL,
 entity = "works",
 filter = "cites:W2755950973",
 date_from = "2022-01-01",
 date_to = "2022-03-31",
 sort=NULL)

res1 <- oaApiRequest(
    query_url = query1,
    total.count = TRUE,
    verbose = FALSE
    )

This query will return a collection of:

cat(res1$count, "publications")
## 166 publications

Let’s to download it:

res1 <- oaApiRequest(
    query_url = query1,
    total.count = FALSE,
    verbose = FALSE
    )

Convert it into a data frame:

df <- oa2df(res1, entity = "works")

and then into a bibliometrix object:

M <- oa2bibliometrix(df)

dplyr::glimpse(M)
## Rows: 166
## Columns: 37
## $ AU            <chr> "CHENG WANG;TAO LV;RONGJIANG CAI;JIANFENG XU;LIYA WANG",…
## $ RP            <chr> "SCHOOL OF ECONOMICS AND MANAGEMENT, CHINA UNIVERSITY OF…
## $ C1            <chr> "SCHOOL OF ECONOMICS AND MANAGEMENT, CHINA UNIVERSITY OF…
## $ AU_UN         <chr> "CHINA UNIVERSITY OF MINING AND TECHNOLOGY;CHINA UNIVERS…
## $ AU_CO         <chr> "CHINA;CHINA;CHINA;CHINA;NA", "ITALY;NA;NA", "SOUTH KORE…
## $ ID            <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", …
## $ id_url        <chr> "https://openalex.org/W4220662981", "https://openalex.or…
## $ TI            <chr> "BIBLIOMETRIC ANALYSIS OF MULTI-LEVEL PERSPECTIVE ON SUS…
## $ author        <list> [<data.frame[5 x 10]>], [<data.frame[3 x 10]>], [<data.…
## $ AB            <chr> "THE MULTI-LEVEL PERSPECTIVE (MLP) IS A PROMINENT FRAMEW…
## $ pubdata       <chr> "2022-03-31", "2022-03-31", "2022-03-31", "2022-03-29", …
## $ SO            <chr> "SUSTAINABILITY", "EUROPEAN JOURNAL OF INNOVATION MANAGE…
## $ SO_ID         <chr> "https://openalex.org/V10134376", "https://openalex.org/…
## $ PU            <chr> "MDPI AG", "Emerald (MCB UP)", "MDPI AG", "Emerald (MCB …
## $ IS            <list> "2071-1050", <"1460-1060", "1758-7115">, <"1661-7827", …
## $ URL           <chr> "https://doi.org/10.3390/su14074145", "https://doi.org/1…
## $ first_page    <chr> "4145", NA, "4165", NA, NA, "1073", "1082", NA, NA, NA, …
## $ last_page     <chr> "4145", NA, "4165", NA, NA, "1073", "1082", NA, NA, NA, …
## $ volume        <chr> "14", NA, "19", NA, "9", "14", "14", NA, NA, NA, "14", "…
## $ issue         <chr> "7", NA, "7", NA, NA, "7", "7", NA, NA, NA, "7", "4", NA…
## $ OA            <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, …
## $ TC            <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ TCperYear     <list> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ PY            <int> 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 20…
## $ cited_by_url  <chr> "https://api.openalex.org/works?filter=cites:W4220662981…
## $ ids           <list> [[<data.frame[2 x 2]>]], [[<data.frame[2 x 2]>]], [[<da…
## $ DI            <chr> "https://doi.org/10.3390/su14074145", "https://doi.org/1…
## $ DT            <chr> "JOURNAL-ARTICLE", "JOURNAL-ARTICLE", "JOURNAL-ARTICLE",…
## $ CR            <chr> "https://openalex.org/W1902979073;https://openalex.org/W…
## $ related_works <list> <"https://openalex.org/W2578464", "https://openalex.org…
## $ concept       <list> <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>,…
## $ id_oa         <chr> "W4220662981", "W4220731660", "W4220971062", "W422071230…
## $ DB            <chr> "openalex", "openalex", "openalex", "openalex", "openale…
## $ JI            <chr> "V10134376", "V90149737", "V15239247", "V20489460", "V25…
## $ J9            <chr> "V10134376", "V90149737", "V15239247", "V20489460", "V25…
## $ SR_FULL       <chr> "CHENG WANG, 2022, V10134376", "GIANLUCA ELIA, 2022, V90…
## $ SR            <chr> "CHENG WANG, 2022, V10134376", "GIANLUCA ELIA, 2022, V90…