Changelog
Source:NEWS.md
openalexPro 0.18.1
- DuckDB connections no longer print duckdb 2.0’s “storing downloaded extensions and secrets under ~/.duckdb” message (up to 60 times per run), and no longer ask to create
~/.duckdbin interactive sessions. openalexPro uses the location duckdb would choose itself (~/.duckdbif it exists, a temporary directory otherwise); aduckdb.homeoption orDUCKDB_R_HOMEyou set is still respected (#88).
openalexPro 0.18.0
-
pro_collection(refresh = TRUE)now makes the members match the query: the query’s IDs are fetched withpro_fetch()(select = "id", the same credits as an import), new ones are added and members that no longer match are removed (free; 10,000 added or 100 removed per request). The collection keeps its ID. Before,refreshimported again, which only adds, so works that no longer matched stayed in the collection. -
pro_collection(refresh = TRUE)takes over a collection of the same name (ignoring case) that is not recorded inproject_folder, e.g. after the local folder was deleted or on another machine: same ID, members synced, folder written again. Withoutrefreshit still stops, and the message now mentionsrefresh = TRUE. -
pro_collection(refresh = TRUE)with a changed query keeps the collection and its ID and syncs the members to the new query. Before, a changed query always deleted the collection and created a new one with a new ID. Withoutrefresh, a changed query still re-creates it. - The list route (a list with
name) also syncs the members instead of only adding:_collection.jsonrecordsaddedandremoved.
openalexPro 0.17.0
-
pro_collection()getsaccess:"shared_by_link"lets anyone with the link or ID view the collection and filter by it,"private"unshares it."public"is passed on, but only OpenAlex can set it for now (HTTP 403, and OpenAlex’s message points toshared_by_link).NULL(default) leaves the access as it is. -
pro_collection(): the records of a single-query collection (selectbeyond"id") are fetched withcorpus = "all". A collection filter alone returns only the core works, so expansion works (DataCite, Zenodo, repositories) were missing fromrecords/. The member IDs were always complete. The examples and vignettes now setcorpus = "all"when filtering by a collection (OQL:works (all corpora) where ...). -
pro_collection()with a list of queries and anamecreates one collection for the whole list. The queries are fetched withpro_fetch()(select = "id", in parallel withworkers) and the IDs added as members (member_ids, 10,000 per request, free). This is for long ID or DOI lists: OpenAlex refuses an import of more than 20,000 characters of OQL (about 600 to 800 DOIs), and with 3,000 DOIs this route was about five times faster than one import per chunk, at the same credits. The queries are kept in_parts.parquet;_collection.jsonstays small. An interrupted run resumes the fetch. Withoutname, a list still gives one collection per element. - A single query that is too long for an import now stops before anything is created, and says how to split it. Earlier versions failed only at the import.
- The documentation no longer says that imports have no length limit.
- Removed a commented-out template line with an emoji from
.onAttach(); in a C/US-ASCII locale R warned that it could not be translated to UTF-8.
openalexPro 0.16.0
- Citation:
citation("openalexPro")now cites the package with its Zenodo DOI and, separately, the openalexPro ecosystem. AddedCITATION.cff(GitHub “Cite this repository”) and.zenodo.json(Zenodo metadata, linking the related ecosystem packages). The author’s ORCID is inDESCRIPTION.
openalexPro 0.15.0
- New
pro_collection(): turns queries frompro_query()into OpenAlex collections (server-side ID sets that can be reused as filters,pro_query(collection = "col_...")). OpenAlex runs the query (an import);pro_collection()waits for it and records everything in<project_folder>/<name>.collection/:_collection.json(query, collection ID, member count, imports, credits), the OQL text, the member IDs as parquet (select = "id", the default; the download is free) and, with more fields inselect, the records. Running it again keeps the collection for the same query (refresh = TRUEimports again), re-creates it for a changed query, and brings the downloads in line withselect(removed fields are dropped locally). A list of queries gives one collection per element. Collections need a personal OpenAlex API key. -
via = "oqo":sampleandseedare now translated by OpenAlex’s/querywith the rest of the query. The workaround that took them out and put them back into the OQO is removed, since OpenAlex fixed the translator (#79).
openalexPro 0.14.1
- License changed from GPL (>= 2) to MIT.
-
infer_json_schema()(and with it the deprecatedpro_request_jsonl_parquet()) unified a column that was text in one file and a number in another to the number type (e.g.VARCHAR+BIGINT->BIGINT,BOOLEAN+BIGINT->BIGINT), so the text values could not be read with that schema. As documented, numeric widening now applies only when every type is numeric, otherwise the column becomesVARCHAR. A column that is null throughout one file (JSONin DuckDB) still takes the numeric type. -
infer_json_schema()withschema_cache_dirstopped with “subscript out of bounds” when the last file failed, instead of reporting the failure and using the other files.
openalexPro 0.14.0
-
oa_works_abstract_sql(), and with it the abstract column thatpro_request_parquet()/pro_fetch()add withenrich = TRUE, failed with current DuckDB (“Deprecated lambda arrow (->) detected”); every conversion of works with abstracts stopped. The SQL now uses thelambda x: ...syntax. - A list download no longer fails with “length(milestones) > 0L is not TRUE” when a query’s last page is exactly full: OpenAlex then sends a cursor to an empty page, which advanced the progress bar by 0 – an error in progressr once the bar is complete (e.g.
pro_query(..., chunk_limit = 200)with chunks of exactly 200 records). - With
delete_input = TRUE,pro_request_parquet()no longer leaves the input JSON behind unnoticed whenunlink()fails silently (e.g. a file still held open): it retries once and then warns, naming files left behind. -
vianow defaults to"oqo"inpro_request(),pro_fetch()andpro_count(): queries are translated once (free) into an OpenAlex Query Object and sent via POST – same results, validated before credits are spent, and more than 100 values per filter, sopro_query(..., chunk_limit = 200)works without further arguments.via = "url"gives the previous behaviour. -
pro_request_parquet()andpro_fetch()gainhive_names: the Hive partition keys for a list of queries, one per nesting level, e.g.hive_names = c("topic", "year")writestopic=<name>/year=<name>/. DefaultNULLkeepsquery,query_l2, … A query namedkey=value(e.g.c("year=2020" = oql1)) supplies its own key, soyear=2020/is written instead ofquery=year=2020/. -
pro_query(oql = , oqo = )accept several queries: a character vector of OQL strings, or a list of OQOs, returns a named list of URLs (names from the input, elsequery_1,query_2, …) thatpro_request()/pro_fetch()run in parallel, one subdirectory per query. A single query is unchanged.
openalexPro 0.13.0
extract_doi(): fewer truncated and false DOIs, new lower
- SICI DOIs ending in the check character
#(...>3.0.CO;2-#) are no longer cut before the#. - Percent-encoding is decoded first, also when encoded twice:
%5B/%5Dand%255B/%255Dbecome[/], and an encoded line break (%0A) ends the DOI. Such DOIs were cut at the first%, so the shortened DOI was the one looked up in OpenAlex. - A DOI followed by an unfilled placeholder (
10.18461/ijfsd.v2i4.%x,10.37002/biobrasil.v%vi%i.798) is no longer recognised. Its part before the%used to be returned as a valid DOI. - A full stop or semicolon at the end is dropped as punctuation:
doi:10.1098/rstb.2016.0173.gives10.1098/rstb.2016.0173. - New argument
lower(defaultTRUE):lower = FALSEkeeps the upper and lower case of the input, e.g. to compare the cleaned DOI with the field it came from.
A query with no results no longer fails to convert
pro_fetch() / pro_request_parquet() stopped with “Cannot extract field from expression”r.*” because it is not a struct” when a query matched no works: with "results": [] DuckDB has no record to infer the columns from. The columns now come from the baseline schema of the entity named in the query record (_query.json), and the output is a zero-row dataset with the usual columns, which arrow::open_dataset() reads.
Fewer, larger Parquet files: compact_parquet, pro_compact_parquet()
pro_request_parquet() writes one Parquet file per API page (up to 200 records), so a large query becomes thousands of small files, which are slow to read. New argument compact_parquet (pro_request_parquet(), pro_fetch(); default NULL keeps one file per page, as before) and new function pro_compact_parquet() (for an existing dataset) combine each query’s page files into files of up to that many records, e.g. 250000. Records, columns and their order do not change. For 1.1 million works, compaction took about 20 seconds; afterwards aggregates and lookups by ID ran 35 to 50 times faster, reading full records with DuckDB 4 times faster, and the dataset was 40% smaller.
A compacted file holds whole consecutive pages and is named after them (results_pages_1-1250.parquet). Files are written one at a time (.part, record count checked, renamed, then the pages deleted), so an interrupted compaction is completed by running it again, and resume = TRUE never converts a compacted page again. A query that cannot be compacted keeps its page files, with a warning. pro_compact_parquet() stops if an openalexSnapshot index (which points to files and row numbers) exists next to the dataset.
Resume in the middle of a query
resume = TRUE no longer fetches an interrupted query again from page 1: it continues after the last saved page. OpenAlex’s cursors are positions in the sort order that do not expire (a cursor from May still worked in October), but contain nothing about the query; so after each page the exact query (the URL, or for via = "oqo" the OQO that ran) and the cursor are written to _paging.json, with the time the cursor was created, which the resume message reports. Anything that cannot be trusted falls back to fetching the query again from page 1, with the reason. Samples and semantic search still start again.
New argument inconsistency_on_resume = c("error", "warning", "ignore", "oldest", "newest") (pro_request(), pro_fetch()): after a resume, duplicates (found exactly, by work ID) and missing records (only as a net difference to OpenAlex’s current count) stop the run by default; nothing is lost, and a rerun with another value applies the choice without downloading again. "oldest" / "newest" remove the other copy from its page file. The resume is recorded in _query.json.
Readable query files for papers: _query_oql.txt, _query_oql.html
Next to _query.json, each downloaded query now gets its OQL – OpenAlex’s readable rendering of the query that ran – as plain text (to paste into a methods section) and as a self-contained HTML page with highlighted keywords, OpenAlex IDs linked to their records, and the exact OQO. Because OpenAlex’s rendering can be lossy in some details, the OQL is translated back and compared: the files say whether it reproduces the query exactly. Both use OpenAlex’s free /query endpoint (two calls per query); if it is unreachable the download is unaffected and the files are marked “not checked”. Both are copied into the Parquet partition.
For a list of queries, _queries_oql.txt and _queries_oql.html at the top of the output summarise all queries in list order – name, records, whether the OQL is exact, the OQL – with totals, for a paper’s supplement (queries skipped by resume included, failed ones listed as not downloaded).
Test recordings refreshed
All recorded API responses were re-recorded from the live API (with the key sent as a header and masked). The snapshot differences were checked: only data drift (counts, citations, one record with fewer locations) and fields OpenAlex has added since spring (study_designs, volume, awards details, observed_orcids, location doi / listed_in, meta.x_query); no field was removed. The URL / OQO equivalence tests passed again on the fresh data, and a pro_count() comparison was added. inst/scripts/record_cassettes.R now records all tests even when snapshots fail (testthat stopped after 10 failures and left later cassettes unrecorded, while reporting success) and stops if any cassette is missing.
Lossless queries: via = "oqo", query record, cost, key as header
-
via = "oqo"(pro_request(),pro_fetch(),pro_count(); default"url", unchanged): each query is translated once (free, with validation before any credits are spent) into an OpenAlex Query Object and sent via POST. Same results – a new test downloads the same queries both ways and compares the complete result sets. No URL length limit and more than 100 values per filter, sopro_query(..., chunk_limit = 200)fetches DOI and OpenAlex ID lists in about one request per chunk, still in parallel. Single records stay GET. -
_query.jsonper query records the URL, how it was sent, the query as OpenAlex ran it (OQL, OQO), records, requests, credits, cost and time; it is copied into the Parquet partition, so it survivesdelete_input.pro_request()reports the total cost. -
The API key is sent as an
Authorization: Bearerheader, never in the URL, so it no longer appears in URLs, logs, error messages or recorded test responses. - With
via = "url", a filter with more than 100 values now stops before sending (OpenAlex rejects it), suggestingchunk_limitorvia = "oqo".
OQL and OQO queries
pro_query() gains oql and oqo (both default NULL, behaviour unchanged) for OpenAlex’s query language and its JSON form, which express what the classic filter syntax cannot, such as nested and / or conditions:
pro_query(oql = "works where year >= (2020) and (title has (coral) or title has (reef))")
pro_query(oqo = list(get_rows = "works",
filter_rows = list(list(column_id = "publication_year", value = 2020))))The URL targets the API root and runs through pro_request(), pro_count() and pro_fetch() unchanged. Entity, conditions, grouping, sample and corpus belong inside the query; combining it with entity, id, doi, search arguments, group_by or filters is an error, because OpenAlex would silently ignore them. select and options are passed alongside. An invalid query fails with OpenAlex’s parse error and position.
pro_request() now detects grouped results from the response (meta$groups_count) instead of looking for group_by= in the URL, so grouping inside an OQL / OQO query is saved and converted correctly.
pro_fetch() gains download_workers
Downloading is limited by the API, converting by CPU and memory, so the best number of workers differs. pro_fetch() used workers for both steps. download_workers (default workers, so existing calls are unchanged) now sets the download workers separately; workers sets the conversion workers.
Download robustness: failing queries, paging parameters, semantic search
-
A failing query no longer stops a list download. With a list of queries, an error in one (e.g. HTTP 404 for an ID that does not exist) aborted the whole run. Now the other queries complete, and one error at the end names each failed query with OpenAlex’s reason. Failed queries keep their
00_in.progressmarker, soresume = TRUEfetches only those again. -
Semantic search works with
pro_request()/pro_fetch(). The download always addedcursor=*, which OpenAlex rejects for semantic search (HTTP 400). Semantic search is now fetched as its single page of at most 50 results. -
Paging parameters are no longer silently overwritten. A
per_pagein the query (1–200) is kept;pageandcursorare replaced by cursor paging with a warning (OpenAlex rejectspagetogether withcursor). Without them, paging is unchanged (per_page = 200, cursor). -
pro_request_parquet(workers = NULL)is sequential, as documented. It ran under whateverfutureplan the user had set, so a parallel plan converted in parallel with a single worker’s memory budget and all cores per process.workersnow alone decides; the user’s plan is restored. -
Samples larger than one page are downloaded completely. OpenAlex ends cursor paging of a
sampleafter the first page, sooptions = list(sample = 1000)silently gave only 200 records. A sample is now paged by page number, up to OpenAlex’s maximum of 10,000. Paging a sample needs aseed; if none is given, one is chosen and reported in a message so the same sample can be fetched again. Samples that fit in one page are unchanged. - Grouped and list results in one conversion stopped with “Mixed entity types found”. The error now names the queries of each kind and how to convert them separately; the JSON files are kept.
Filter and select validation per entity
pro_query() checked filter names and select fields against the lists for works, whatever the entity, so valid entity-specific names were rejected before reaching OpenAlex – e.g. pro_query(entity = "institutions", country_code = "US") or select = "orcid" for authors. Refreshing with update = TRUE did not help, as it fetched the works list again.
opt_filter_names() and opt_select_fields() gain an entity argument (default "works", so existing calls are unchanged) and cache one list per entity; pro_query() validates against the queried entity’s lists. The lists come from OpenAlex’s error message for an invalid name, which costs no credits. An entity without a list (the retired "venues") skips validation and lets OpenAlex answer.
Parsing that message also dropped the first name of every list (e.g. the abstract.search filter, and id, which was patched back in by hand) and left a trailing period on the last select field ("created_date."); both are fixed.
An argument of the functions that send a query, given to pro_query() by mistake (e.g. pro_query(doi = dois, via = "oqo")), was taken as a filter and failed with “Invalid filter name(s): via”. It now says where it belongs: “via is an argument of pro_fetch(), pro_request(), pro_count()”, with an example.
Documentation brought up to date
-
API key name: the vignettes,
CLAUDE.mdand the message ofpro_rate_limit_status()told users to setopenalexPro.apikey, whichpro_api_key()never reads – a key set that way was silently ignored. The correct name is the environment variableopenalexPro.api_key(or the optionopenalexPro$api_key), as the README already said. -
Search syntax: wildcards (
microbio*) and fuzzy terms work only withsearch.exact; the stemmedsearchrejects wildcards with HTTP 400. All three search types cost $0.001 per call (the vignette said $0.0001), and semantic search does not require an API key. -
Entities:
sources,topicsandlocationsreplacevenuesandconceptsin the examples;topics.idreplacesconcepts.id. -
Corpus: the deprecated
include_xpac/is_xpaccontrols are replaced by thecorpusparameter ("core","all","expansion"); combining them is an error at OpenAlex. -
Pipeline: README, vignettes and diagrams describe
pro_request_parquet()instead of the deprecated JSONL pipeline, andpro_fetch()no longer appears to write JSONL files. New sections cover OQL / OQO,resume, error handling and budgets;inst/errorcodes.qmdis rewritten (the “polite pool” no longer exists). - Links point to the current OpenAlex documentation at
help.openalex.org. - The
pro_requestvignette documentspro_request_parquet()(signature, schema inference, failure handling,resume) instead of the deprecated JSONL functions, which are reduced to a pointer to their help pages. - The snapshot vignettes install
openalexSnapshotfrom r-universe (it is available there) and no longer claim that error-raising stubs exist. -
DESCRIPTIONhas a realDescription, andjsonlitemoves from Suggests to Imports:pro_query(oqo = <list>)and every JSON response parse need it, and httr2 does not import it. - Six Mermaid diagrams in the
pro_queryandpro_requestvignettes showed “Syntax error” (unquoted labels containing()or"); they render again.
delete_input no longer deletes pages that failed to convert
With on_error = "warn" or "ignore", pro_request_parquet(delete_input = TRUE) deleted the JSON input even when some files had failed – the only copy of those pages – so resume = TRUE could not recover them. The input is now kept unless every file converted.
Downloads survive network failures and stalls
api_call() retried only on HTTP 429/5xx. A dropped connection or curl error aborted the whole leaf, and a stalled transfer could hang a worker forever. Network failures are now retried with the same backoff, and a transfer below 1 byte/s for 120 s is aborted and retried. Requires httr2 >= 1.0.0.
resume works for a single URL, and in pro_fetch()
pro_request(resume = TRUE) was silently ignored for a single URL and failed with “Directory exists”. A single URL is now treated as one leaf. pro_fetch() gains resume (default FALSE, behaviour unchanged), which completes an interrupted download and conversion and returns a finished run unchanged.
No count request per query before a parallel download
To size its progress bar, pro_request() with a list of queries first sent a count request for every leaf, one after another, before downloading anything. For a chunked DOI / ID list (one page per leaf) that doubled the requests and their cost. Progress now counts leaves, each advancing in fractions as its pages arrive, with no extra requests.
Clearer API errors, and no pointless retries on an exhausted budget
A 4xx error now includes OpenAlex’s own explanation (e.g. which filter name is invalid) instead of only “HTTP 400 Bad Request”. A 429 caused by the daily budget – used up (X-RateLimit-Remaining at zero), or a query refused as costing more than is left ("error": "not_enough_credits") – fails immediately and says when the budget resets, instead of backing off for about 17 minutes before failing. verbose = TRUE no longer prints the API key as part of the URL.
pro_query() no longer fetches the list of valid select fields when no select is given, saving a request per session.
pro_query() knows the current entities
entity now also accepts "sources", "topics" and "locations". "venues" and "concepts" (replaced by sources and topics in OpenAlex) are kept for compatibility. The default is still "works".
Better load balancing for parallel downloads
pro_request() with a list of queries pre-split the leaves into one block per worker, so a worker that drew the large leaves ran on while the others sat idle. Each leaf is now dispatched to the next free worker.
openalexPro 0.12.1
The startup banner pointed at the old r-universe
.onAttach() printed https://rkrug.r-universe.dev/openalexPro. The package has been distributed from https://openalexpro.r-universe.dev since the move to the openalexPro organisation – and DESCRIPTION’s Additional_repositories already said so – so the one URL every user saw on every library(openalexPro) was the one that was wrong.
Also tidies two typos in the same banner (functions definitions, and a space before a comma).
openalexPro 0.12.0
Breaking: pro_request_parquet() no longer hides conversion failures
A JSON file that failed to convert was caught, message()d only when verbose, and the run then reported success anyway. The page was simply absent from the resulting corpus: read_corpus() worked, nothing warned, and every downstream count was quietly wrong. On a large run under memory pressure this is worse than a crash, because a crash at least announces itself.
Failures are now collected, retried once sequentially with the full memory budget (per-file peak memory varies with how large and nested a page is, so sizing the per-worker limit for the worst file would throttle all of them), and whatever still fails is reported according to the new on_error argument: "error" (default) stops and names the files, "warn" warns and returns, "ignore" restores the old silence.
This will stop runs that previously appeared to succeed. That is the point. Pass on_error = "warn" for the closest thing to the old behaviour, but visible.
Each file is now written to a .part sidecar and renamed on success. A parquet footer is written last, so a worker killed mid-COPY used to leave a file that looked plausible to file.exists() but could not be read.
DuckDB connections are configured rather than left at their defaults
New internal .pro_con() factory, mirroring openalexSnapshot:::.oas_con(). Every connection in the package now goes through it, including the schema inference pass and convert_json_to_parquet().
This matters most inside future workers. Each worker used to open a bare dbConnect(duckdb::duckdb()), which means:
- a
memory_limitof ~80% of system RAM per worker – so N workers promised 0.8 x N of the machine, and - a
temp_directoryof.tmprelative to the working directory, shared by every worker, which is the colliding-spill-file corruption openalexSnapshot documents inbuild_citation_index().
Workers now get a per-worker memory budget derived from physical RAM and the worker count, threads = 1 (the processes already saturate the machine), and a private spill directory under tempdir(). memory_limit and retry_memory_limit are exposed for callers who want to set them directly.
Physical RAM is derived without a new dependency or platform code: a bare DuckDB connection’s own memory_limit is 80% of it.
resume for both request functions
pro_request(resume = TRUE) refetches only the leaf queries that did not complete, using the 00_in.progress sentinel each leaf directory already carried and which nothing previously read. pro_request_parquet(resume = TRUE) converts only the files that are not already present – trustworthy because of the .part-and-rename change above.
Previously the only options were overwrite = TRUE (delete everything and refetch) or overwrite = FALSE (hard error). There was no way to continue an interrupted download.
openalexPro 0.11.0
Breaking changes
-
build_corpus_index()andlookup_by_id()are removed. They had been left behind as stubs that raised “moved to the openalexSnapshot package”. That was actively harmful: an exported stub masks the real function whenever both packages are attached, solibrary(openalexSnapshot); library(openalexPro)made the stub win and the call fail. UseopenalexSnapshot::build_corpus_index()andopenalexSnapshot::lookup_by_id().id_block()andread_corpus()are unaffected and remain exported.
Bug fixes
-
extract_doi()no longer truncates DOIs containing<,>,[or]. The character class excluded them, so a SICI-style DOI such as10.1175/1520-0450(1963)002<0713:ooasds>2.0.co;2matched only up to the first<and returned10.1175/1520-0450(1963)002. The truncated remainder then passed the normalisation whitelist, so the function returned a plausible-looking wrong DOI with no warning and noNA– silent corruption rather than a visible failure. Roughly 0.4% of OpenAlex works carry such DOIs (~1.4 million records).Both the match pattern and the normalisation whitelist now admit those characters. Note the fix required reordering rather than escaping: in a POSIX bracket expression a backslash is literal, so
]must be the first character in the class and-the last.This also fixes
openalexConvert’s.normalize_doi(), which delegates here and therefore emitted truncated DOIs into CSL-JSON output.
openalexPro 0.10.4
Internal / Code Quality
pro_request_parquet()refactored into small internal helpers (.prr_prepare_output,.prr_discover_jsons,.prr_infer_schema,.prr_apply_baseline,.prr_fix_json_types,.prr_output_paths,.prr_convert_one) to drop cyclomatic complexity below thegoodpracticethreshold. Behaviour is unchanged.Added tests for
find_oas_binary(),run_oas(),pro_validate_credentials(),prepare_snapshot(), andsample_parquet_n(). Package test coverage rose from ~73% to ~80%.Tests that intentionally exercise the deprecated
pro_request_jsonl_R()/pro_request_jsonl_parquet()pipeline now wrap those calls insuppressWarnings()to keep test output clean.Added a
.lintrconfiguration settingline_length_linter(100)(modern tidyverse default) and reflowed remaining long lines in package code.
New Features
pro_request_parquet()gains aschemaparameter (default"auto") that uses pre-built field-type schemas — inferred from the complete OpenAlex snapshot — to resolve ambiguous DuckDB type inference on small API pages. This eliminatesVARCHAR[] → JSONtype-conflict errors when unioning parquet files from separate API calls (e.g. keypaper + cited + citing in a snowball search).New
oa_cache_schema()function copies schemas from a snapshot metadata directory (e.g./Volumes/openalex/openalex-snapshot_metadata) into the user-level cache so the correct types are available even when the volume is not mounted.Factory-default schemas for all 21 OpenAlex entity types are now bundled in
inst/extdata/schemata/and used automatically whenschema = "auto", so the feature works out-of-the-box without any manual cache population.
Bug Fixes
oa_works_abstract_sql()now castsabstract_inverted_indexthrough JSON (::JSON::MAP(VARCHAR, BIGINT[])) before callingmap_entries(). This fixes abstract reconstruction when DuckDB infers the column asSTRUCT(which happens when a sampled API page contains no duplicate-cased keys) rather thanMAP. The expression now handlesSTRUCT,MAP, andVARCHARinputs uniformly (#XXX).pro_request_parquet()now overrides the inferred DuckDB type ofabstract_inverted_indextoMAP(VARCHAR, BIGINT[])when building the paginatedread_jsonschema, so the fix applies even before the abstract SQL runs.
Breaking Changes
snapshot_to_parquet(),build_corpus_index(), andlookup_by_id()have moved to the openalexSnapshot package. Calling them inopenalexPronow raises an informative error. Their_Rvariants have been removed entirely.pro_request_parquet_R()andpro_fetch_R()removed.pro_request_parquet()andpro_fetch()are now the single pure-R/DuckDB implementations.
Internal Changes
-
oa_works_abstract_sql(),oa_works_citation_sql(), andoa_normalize_duckdb_type()are now implemented in R (behaviour unchanged).
openalexPro 0.9.0
New Features
pro_rate_limit_status()— query your OpenAlex API rate-limit status (daily budget, used, remaining, prepaid balance, reset time, per-endpoint costs). Returns a list invisibly; prints a formatted summary whenverbose = TRUE.New debug option
openalexPro.ratelimit_check: when set toTRUEviaoptions(openalexPro.ratelimit_check = TRUE), every API call prints the current rate-limit status (budget, usage, remaining, reset time) as a message before the request is sent. Internally handled inapi_call()usingpro_rate_limit_status(verbose = TRUE). A recursion guard temporarily disables the option during the nested rate-limit request.
openalexPro 0.8.1
Bug Fixes
pro_request()list method now respects theoverwriteparameter. Previously, whenquery_urlwas a list, the top-leveloutputdirectory was neither checked nor deleted regardless ofoverwrite. It now errors if the directory exists andoverwrite = FALSE, and deletes it upfront ifoverwrite = TRUE.pro_fetch()now deletes all three subdirectories (json,jsonl,parquet) upfront before the pipeline starts whenoverwrite = TRUE, rather than delegating deletion to each sub-function individually. If any of the subdirectories exist andoverwrite = FALSE, the function now errors immediately with a clear message listing which directories already exist.
openalexPro 0.8.0
New Features
-
pro_request(),pro_request_jsonl(), andpro_request_jsonl_parquet()now accept nested lists of query URLs. Each nesting level is preserved as a subdirectory in the output, and the parquet stage converts directory depth into hive-style partition keys: depth 1 →query=<name>, depth 2 →query_l2=<name>, depth 3 →query_l3=<name>, etc. The resulting dataset is readable witharrow::open_dataset()and the partition columns appear as regular columns.pro_fetch()inherits this behaviour automatically. A new internal helpercollect_leaf_queries()performs the recursive list flattening.
openalexPro 0.7.0
Breaking Changes
snapshot_to_parquet()has a new signature. The oldsnapshot_dirandparquet_dirparameters are replaced by a singleroot_dirparameter that matches the directory layout used by the companionopenalex-snapshotbinary. The function now delegates to the binary rather than performing conversion in R. Migration: replacesnapshot_to_parquet(snapshot_dir = "...", parquet_dir = "...")withsnapshot_to_parquet(root_dir = "...").build_corpus_index()has a new signature. The oldcorpus_dirparameter is replaced byroot_dir. The function now delegates to theopenalex-snapshotbinary. Migration: replacebuild_corpus_index(corpus_dir = "...")withbuild_corpus_index(root_dir = "...").lookup_by_id()has a new signature. The oldindex_fileandoutputparameters are replaced byroot_dirandproject_dir(consistent with the project-folder convention used bypro_request()andpro_fetch()). The function now delegates to theopenalex-snapshotbinary. Migration: replacelookup_by_id(index_file = "...", output = "...")withlookup_by_id(root_dir = "...", project_dir = "...").
New Features
-
Pure-R / DuckDB fallback variants are now exported as separate functions:
-
snapshot_to_parquet_R()— original R implementation of snapshot conversion (uses DuckDB + arrow, no external binary required) -
build_corpus_index_R()— original R implementation of index building -
lookup_by_id_R()— original R implementation of ID-based record lookup
These retain the original parameter names and are useful when the
openalex-snapshotbinary is unavailable. -
-
find_oas_binary()andrun_oas()are exported internal helpers for resolving and invoking theopenalex-snapshotbinary. They support:- Explicit
oas_binargument options(openalexPro.oas_bin = "/path/to/binary")- PATH search via
Sys.which("openalex-snapshot")
- Explicit
inst/Makefile.snapshotupdated to use theopenalex-snapshotbinary directly (replacingRscriptinvocations of the now-renamed R functions).
openalexPro 0.6.1
Bug Fixes
- Manual add the
idfield to theopt_select_names()as it is missing from the returned list from OpenAlex
Changes
Normalized
api_keyhandling across API-calling functions:pro_request(),pro_fetch(),pro_count(), andpro_download_content()now acceptapi_key = NULLorapi_key = "". In that case, requests are sent without an API key (subject to OpenAlex’s unauthenticated limits).Added explicit
api_keytype validation in API-calling functions. Accepted inputs are now limited toNULLor a length-1 character string.Updated
pro_rate_limit_status()to handleapi_key = NULLsafely (informational message +FALSEreturn), and aligned documentation.
Testing and Tooling
Added opt-in live API contract tests (
tests/testthat/test-900-live_api_contracts.R) gated byOPENALEXPRO_LIVE_TESTS=trueand a non-dummyopenalexPro.apikey.Added
inst/scripts/record_cassettes.Rand recording safeguards to prevent accidental re-recording with invalid credentials.Reduced warning noise in test runs by cleaning up deprecated-search warning handling and removing unused cassette hooks.
openalexPro 0.6.0
New Features
Added
pro_rate_limit_status()to query the OpenAlex rate-limit endpoint (GET /rate-limit). Returns the full rate-limit JSON invisibly (daily budget, used, remaining, prepaid balance, per-endpoint costs, reset time). Prints a human-readable summary viamessage()whenverbose = TRUE(the default). ReturnsFALSEfor a missing or invalid API key, andNULLon a network error, so callers can distinguish auth problems from transient failures.pro_validate_credentials()refactored to usepro_rate_limit_status()internally instead of making a separatepro_count()request. Behaviour and return value are unchanged.Added
pro_download_content()to download full-text PDFs (format = "pdf") or TEI XML (format = "grobid-xml") from the OpenAlex content endpoint (content.openalex.org). Accepts a vector of work IDs, supports parallel downloads viaworkers, and returns a data frame with per-file status ("ok"/"not_found"/"error"). Note: content downloads cost $0.01 per file.-
Added
search.exactandsearch.semanticparameters topro_query(), matching the new OpenAlex search API:-
search.exact: searches without stemming or stop-word removal; supports boolean operators, quoted phrases, proximity (~N), and wildcards. -
search.semantic: AI embedding-based search that matches by conceptual meaning rather than keywords (max 50 results, max 1 req/sec). -
search: now documented to support the full boolean/phrase/wildcard syntax in addition to its existing stemmed matching.
-
Exported
infer_json_schema()for direct use. Infers a unified DuckDB columns clause from a set of JSON/NDJSON files via per-fileDESCRIBEqueries with type-widening and optional two-level disk caching (schema_cache_dir).
Internal Changes
-
pro_rate_limit_status()andpro_download_content()now route their HTTP requests through the internalapi_call()helper, unifying retry logic and error handling across all real API call sites.suppressMessages()is used to suppressapi_call()’s internal logging so each function emits its own user-facing messages.pro_download_content()now also sends aUser-Agentheader (previously omitted).
Deprecations
- Filter arguments with a
.searchsuffix (e.g.title_and_abstract.search = "...") are deprecated by the OpenAlex API. They still work but now emit a warning. Use thesearchparameter ofpro_query()instead:pro_query(entity = "works", search = "your terms"). See https://developers.openalex.org/guides/searching for details.
Bug Fixes
-
Fixed Windows path-normalization failures in
snapshot_to_parquet(),build_corpus_index(),lookup_by_id(), andpro_request_jsonl_parquet(). On Windows,normalizePath()can return 8.3 short names (e.g.RUNNER~1) fortempdir()-derived paths whilelist.files()and DuckDB resolve to long names (runneradmin). Resume detection insnapshot_to_parquet()used%in%on paths with mixed separators (\vs/), causing already-converted files to be reconverted.build_corpus_index()embeddedsnapshot_dir(with\) inside a DuckDBregexp_replacepattern, which never matched — so the full absolute path was stored in the index and later doubled bylookup_by_id().pro_request_jsonl_parquet()usednormalizePathstring comparison to detect subdirectories, which always failed, placing every output file in a spuriousquery=<dirname>subdirectory.Fixes: (1) normalize separators to
/withgsub("\\\\", "/", ...)on both sides of%in%comparisons; (2) compute relative paths in R using path-depth counting (strsplit(path, "/")then indexed extraction) rather than string-matching absolute paths — immune to 8.3 vs long-name differences;- pass the relative path as a SQL literal in
build_corpus_index()instead of computing it inside DuckDB with a regex.
- pass the relative path as a SQL literal in
Changes
- Schema cache per-file CSVs renamed from
%06d_<basename>.schema.csvto<update_date>_<part_name>.csv(e.g.2024-01-15_part_001.csv), making each cache file directly traceable to its source.gz.
Breaking Changes
- Removed
mailtoparameter from all API functions (pro_request(),pro_fetch(),pro_count(),pro_validate_credentials()). OpenAlex no longer uses email addresses for polite-pool access. -
api_keyhandling was tightened in 0.6.0 forpro_request(),pro_fetch(), andpro_count().
Note: this was later relaxed again in development; current development allowsapi_key = NULL/""and runs in unauthenticated mode. - Simplified User-Agent string from
openalexPro v[VERSION] (mailto:[EMAIL])toopenalexPro/[VERSION].
openalexPro 0.5.0
New Features
Snapshot Handling
- Added
prepare_snapshot()function for setting up a directory with Makefile and documentation for managing OpenAlex snapshots. - Added
Makefile.snapshotininst/for automating snapshot download, conversion, and indexing. Includes targets forsnapshot,parquet,parquet_index, and automatic renaming of existing data with release dates. - Added
snapshot_to_parquet()function for converting OpenAlex snapshot NDJSON files to Parquet format using DuckDB. Processes each.gzfile individually with per-file resume support. Supports parallel processing viaworkers(usingfuture_lapply()) and unified schema inference viasample_size. - Added
build_corpus_index()function for creating memory-efficient Parquet indexes for fast ID lookups. Handles 300M+ records by processing parquet files individually, with optional parallelization viaworkersand progress reporting viaprogressr. The index file is auto-named and placed alongside the corpus directory. - Added
lookup_by_id()function for fast record retrieval from a parquet corpus using pre-built indexes. Uses Arrow for index filtering with automatic ID normalization. Supports parallel reads viaworkersand streaming to parquet viaoutputfor millions of IDs without loading into memory. - Added
snapshot_filter_ids()function for filtering snapshot data by ID lists. - Added
id_block()helper function for computing ID block partitions.
Documentation
- Added
snapshot.qmdvignette with comprehensive guide on downloading, converting, and querying OpenAlex snapshots locally.
Changes
- Refactored
snapshot_to_parquet()to process each.gzfile individually instead of all at once. This reduces memory usage, enables per-file resume on interruption, and shows progress with ETA. Theworkersparameter now controls parallelfutureworkers instead of DuckDB threads. Addedsample_sizeparameter for schema inference. - Extracted
infer_json_schema()andconvert_json_to_parquet()internal helpers, shared by bothsnapshot_to_parquet()andpro_request_jsonl_parquet(). - Refactored
pro_request_jsonl_parquet()to per-file conversion withfuture_lapply()parallelization. Removes hive partitioning bypage; subfolder structure is preserved directly. Addedworkersparameter. Removedprogressparameter (replaced byprogressr).
Bug Fixes
- Fixed vignette parse errors in
pro_query.qmd(malformed code block closings). - Fixed out-of-memory crash in
snapshot_to_parquet()whensample_sizeexceeded the number of available files (e.g.sample_size = 10000with 1981 works files). Schema inference now processes one file at a time instead of a single bulk DuckDB query. - Fixed
duplicate key "as"crash when converting theworksdataset.abstract_inverted_indexis now stored asVARCHAR(raw JSON string) rather than aSTRUCT. DuckDB folds struct field names to lowercase, causing a collision between the valid JSON keys"as"and"As"in this field. Storing asVARCHARavoids struct parsing entirely and preserves the data. Parse individual values withjsonlite::fromJSON()when needed. - Fixed DuckDB temp file IO errors during
snapshot_to_parquet()by exposing aTEMP_DIRvariable inMakefile.snapshot(default/tmp).
Changes
-
snapshot_to_parquet()schema inference now runs one DuckDBDESCRIBEper file instead of a single query across all sampled files. Results are cached in<parquet_ds>/.schema_cache/: per-file CSVs (<update_date>_<part_name>.csv) enable mid-run resume; a unifiedunified_schema.csvis loaded on subsequent runs to skip inference entirely. Deleteunified_schema.csvto force re-inference.
openalexPro 0.4.1
- Standardised progressbar handling
- Changed default pages from 1,000 to 10,000
- Refactored
pro_queryand removedmultiple_idsargument using Claude and expanded tests and added vignette. - Added creation of
00_completedin output directory ofjson,jsonlandparquetfolders upon successful completion - Changed api key and email handling. Removed oap_mail()_ and oap_apikey() and simplified handling of api key and email to only use environmental variables
openalexPro.emailandopenalexPro.apikey - Added unified schema inference to
pro_request_jsonl_parquet()to prevent schema conflicts when reading combined Parquet datasets. Newsample_sizeparameter controls schema inference sampling. This fixes “Unsupported cast from string to struct” errors when fields have different types across JSONL files (e.g.,apc_paidbeingnullin some files and a struct in others). - Removed
harmonize_parquet_schemata()as it is no longer needed with the new unified schema inference. - Increased default n umber of pages to be read by
request_json()from 1000 to 10000 to allow the initially planned 2,000,000 work download.
openalexPro 0.4.0
CI and coverage tweaks for CRAN readiness.
splitting snowball functionality into openalexSnowball
openalexPro 0.3.1
- Added
pro_fetch()withproject_foldersupport for structured outputs. - Added progress reporting and parallelization for
pro_request_jsonl(). - Added
sample_parquet_n()random sampling utilities withselectsupport. - Improved
count_onlyoutput to return a data frame with an error column.
openalexPro 0.3.0
- Added
count_onlysupport forpro_request()and related helpers. - Added DOI handling improvements and API call fixes.
openalexPro 0.2.0
- Introduced
pro_query()as the package-native query builder with chunking. - Added snowball search utilities and citation edge extraction workflow.
- Expanded conversion pipeline tests and VCR-based API fixtures.
- Added
extract_doi()helpers and compatibility reporting artifacts.