Query the bioRxiv or medRxiv API (https://api.biorxiv.org/) for
preprints and return the results as an sm_corpus.
The API provides date-range-based content retrieval. If query is
supplied, results are filtered locally by title/abstract matching.
Usage
sm_fetch_biorxiv(
query = NULL,
server = c("biorxiv", "medrxiv"),
from_date = NULL,
to_date = NULL,
n_max = 200L,
verbose = TRUE,
call = rlang::caller_env()
)Arguments
- query
Optional search string for local filtering of results.
- server
One of
"biorxiv"or"medrxiv".- from_date
Start date in
"YYYY-MM-DD"format. Defaults to 30 days ago.- to_date
End date in
"YYYY-MM-DD"format. Defaults to today.- n_max
Maximum number of results to return (default 200).
- verbose
Print progress messages?
- call
Caller environment for error reporting.
Failed requests
Native requests retry transient server and network failures, and short
announced rate-limit waits. Long waits abort immediately. If a later
page fails, the error inherits from scimapR_fetch_incomplete and holds
the earlier parsed works in rlang::last_error()$partial. Their metadata
records fetch_incomplete with the source, received and expected counts,
and failure reason. If those pages cannot be parsed, partial is NULL.
The default remains an error; an incomplete fetch is never returned as
an ordinary successful result.
Examples
# \donttest{
# Queries the bioRxiv web API.
if (requireNamespace("curl", quietly = TRUE) && curl::has_internet()) {
corpus <- try(sm_fetch_biorxiv(
from_date = "2024-01-01",
to_date = "2024-01-02",
n_max = 5
))
print(corpus)
}
#> ℹ Fetching from biorxiv (2024-01-01 to 2024-01-02)...
#> ℹ Fetched 30 / 5 biorxiv preprints.
#> ✔ Parsed 5 biorxiv preprints into sm_corpus.
#>
#> ── <sm_corpus> ─────────────────────────────────────────────────────────────────
#> Works: 5 | Authors: 37 | Institutions: 0
#> Years: 2024 - 2024
#> Sources (journals): 0
#> Embeddings: none
#> Provenance: biorxiv (5)
#> Status: Unlocked (last refreshed: never)
# }