Status: beta (was alpha). openalexAPI is now on the openalexPro r-universe:
install.packages("openalexAPI", repos = c("https://openalexpro.r-universe.dev", "https://cloud.r-project.org")).
New route GET /links: the corpus's link table (links/ next to the
corpus, STANDARD.md ยง7), shaped like OpenAlex's /links. Records come as
stored, so all link types and relations of the source are served (e.g.
every related identifier of an openalexImportZenodo corpus, also those
without an OpenAlex link type) with their extra columns. Filters origin,
target (any ID or DOI form), link_type (short or URL), relation,
origin_in_corpus, target_in_corpus, with |, ! and null; parsed
locally. No work needs to be named; group_by on link_type, relation
and the *_in_corpus flags; sort, select, paging. /corpus reports
the number of links. Cached databases are rebuilt once.
query=a/, year=2020/,
any key at any depth, also mixed in one corpus) are now kept per work, with
all values of a work that is in several partitions, and /corpus lists
them with the number of works per value. They are not served as fields of
the works. Follows the ecosystem standard (STANDARD.md L5a, L5c; #12).
Cached databases are rebuilt once.abstract_inverted_index, is now part of openalexAPI.DESCRIPTION declares the ecosystem standard it follows
(Config/openalexPro/standard: 0.1).prepare_corpus() (and so serve_corpus()) keeps the database in an
API folder next to the corpus, by default, instead of
tools::R_user_dir("openalexAPI", "cache"). For a corpus in
my_project/parquet that is my_project/API/, in the project folder as
in openalexPro. Pass cache_dir to keep it elsewhere; existing databases in
the old location are not moved and are rebuilt once.prepare_corpus() builds a new database, it deletes the databases of
earlier states of the same corpus. Database files are now named
oaapi_<corpus>_<state>.duckdb.serve_corpus() failed with "shared_home can't be applied to the
database instance" when the database was still open in the R session (for
example from an earlier, interrupted serve_corpus()). It now reuses the
open database.serve_corpus() (and the Docker image) prints the addresses of the web page
and the API when the server starts. In Docker it shows the container's
port (8000), not the one published on the host.cited_by_count (for example one imported
from Zenodo or policy sources) failed with "Unknown select field(s)".abstract_inverted_index is a JSON string, now read as a map. Records whose
index repeats a word (about 0.6 % in the snapshot) keep their abstract, with
the positions merged. Cached databases are rebuilt once.ghcr.io/openalexpro/openalexapi
(amd64 and arm64). docker/compose.yaml runs it behind Caddy (HTTPS), so a
server needs only Docker, two configuration files and the Parquet files;
see the vignette. docker/Dockerfile builds the image from a checkout./query fails with a 5xx
(macOS CI runs failed on OpenAlex's 504s); the server's own errors still fail.DESCRIPTION, CITATION,
CITATION.cff and the README.First version (alpha): not on r-universe, installed from GitHub.
tools/oql_coverage.R):
authorships.institutions.lineage, authorships.author.orcid,
funders.id, publication_date, from_created_date / to_created_date,
citation_normalized_percentile.value / .is_in_top_1_percent /
.is_in_top_10_percent, open_access.any_repository_has_fulltext,
ids.pmid, ids.pmcid, primary_location.source.issn,
primary_location.source.publisher_lineage (host_organization_lineage),
primary_topic.subfield.id; group_by on those OpenAlex can group by.raw_affiliation_strings.search[.exact], raw_author_name.search[.exact]),
and proximity search ("a"~N~"b", chains with a distance per pair,
"a b"~N; N up to 1000). Phrases and proximity in the stemmed search
columns match word stems ("coral reefs" also finds "coral reef").group_by on publisher lineage shows the publishers' names.group_by,
comparisons or nested queries. Live comparison with OpenAlex
(tools/live_parity.R): all 47 filter and group_by checks equal, the 5
full-text searches differ as expected (OpenAlex also searches full texts).tools/benchmark.R). A
wildcard-only search sorted by relevance no longer fails.group_by matches OpenAlex in two more details, found by a live comparison
(tools/live_parity.R: 29 of 33 checks equal, the 4 search checks differ as
expected): slug keys are URL-encoded (source-types/ebook%20platform), and
true/false columns list both values, also with count 0.vignette("openalexAPI"), pkgdown site config,
CITATION / CITATION.cff / .zenodo.json.prepare_corpus() reads a Parquet corpus into a cached DuckDB database:
one row per work, IDs and DOIs matched in any form, the abstract as text,
and abstract_inverted_index rebuilt for corpora from the JSONL path.serve_corpus() serves it like the OpenAlex API (GET /works,
GET /works/{id}, GET /?oql= / ?oqo=, POST /, POST /query,
GET /corpus), so openalexPro downloads from it unchanged. Classic URLs and
OQL are translated by OpenAlex's free /query; an OQO runs offline.oqo_to_sql() compiles an OQO to DuckDB SQL: AND / OR / negation, sort,
null values (field missing), and 33 of the most-used works filters.search / search.exact and the <field>.search[.exact] filters for
fulltext, title_and_abstract, display_name and abstract. All words
must match (as in OpenAlex), quoted phrases in order, wildcards with
.exact; ranked by BM25 as relevance_score, the default sort when
searching. The stemmer (Porter) folds more word forms than OpenAlex's, so
stemmed counts can be higher; proximity ("a b"~N) is not supported.group_by (one dimension): works counted once per key, keys and response
shape as OpenAlex's (group_by with key, key_display_name, count;
no results), sorted by count or key, paged; :include_unknown adds the
works without a value. Countries, languages and licenses show the code as
display name (OpenAlex shows the full name)./ (/app, served from inst/www, no build step): search and
filters or OQL, group_by as bars (a click narrows the filters to that
group), records with authors and relevance, paging, the translated OQL, and
"Copy API URL" for openalexPro::pro_fetch(). Light and dark, phone width.
The page's files are linked with a stamp of their content, so a browser
loads new ones after an upgrade.publication_year,
cited_by_count, fwci, publication_date, is_retracted,
is_paratext) are converted back, with a count of unreadable values. Other
columns are served in the common type DuckDB reads them as. Extra,
non-OpenAlex columns are served as they are (not filterable).members/) are skipped; a sample spanning pages is the same on every page;
GET /works/{id} also takes a DOI and select./query endpoint translates classic filters and searches
into OQO (tools/spike_translate.R, inst/extdata/oqo_translations.csv),
which defines the column registry.