if (FALSE) {
### EXAMPLE 1: Full record about an entity.
# Query to obtain all information about a particular work/author/institution/etc.:
# The following paper is associated to the OpenAlex-id W2755950973.
# Aria, M., & Cuccurullo, C. (2017). bibliometrix:
# An R-tool for comprehensive science mapping analysis.
# Journal of informetrics, 11(4), 959-975.
res <- oa_request(query_url = "https://api.openalex.org/works/W2755950973")
# The author Massimo Aria is associated to the OpenAlex-id A5069892096.
query_author <- oa_query(
identifier = "A5069892096",
entity = "authors"
)
query_author
res <- oa_request(
query_url = query_author,
count_only = FALSE,
verbose = FALSE
)
### EXAMPLE 2: all works citing a particular work.
# Query to search all works citing the article:
# Aria, M., & Cuccurullo, C. (2017). bibliometrix:
# An R-tool for comprehensive science mapping analysis.
# Journal of informetrics, 11(4), 959-975.
# published in 2021.
# The paper is associated to the OpenAlex id W2755950973.
# Results have to be sorted by relevance score in a descending order.
query2 <- oa_query(
identifier = NULL,
entity = "works",
cites = "W2755950973",
from_publication_date = "2021-12-01",
to_publication_date = "2021-12-31",
search = NULL,
endpoint = "https://api.openalex.org"
)
res2 <- oa_request(
query_url = query2,
count_only = FALSE,
verbose = FALSE
)
### EXAMPLE 3: All works matching a string in their title
# Query to search all works containing the exact string
# "bibliometric analysis" OR "science mapping" in the title, published in 2020 or 2021.
# Results have to be sorted by relevance score in a descending order.
query3 <- oa_query(
entity = "works",
title.search = c("bibliometric analysis", "science mapping"),
from_publication_date = "2021-12-01",
to_publication_date = "2021-12-31"
)
res3 <- oa_request(
query_url = query3,
count_only = FALSE,
verbose = FALSE
)
### EXAMPLE 4: How to check how many works match a query
# Query to search all works containing the exact string
# "bibliometric analysis" OR "science mapping" in the title, published in 2020 or 2021.
# Query only to know how many works could be retrieved (count_only=TRUE)
query4 <- oa_query(
entity = "works",
title.search = c("bibliometric analysis", "science mapping"),
from_publication_date = "2020-01-01",
to_publication_date = "2021-12-31"
)
res4 <- oa_request(
query_url = query4,
count_only = TRUE,
verbose = FALSE
)
res4$count # number of items retrieved by our query
}
Run the code above in your browser using DataLab