API reference
Generated from the source with mkdocstrings.
Client
bibliofabric.dryad.DryadClient
Client for the Dryad API v2.
Public metadata reads need no credentials: the client reads
anonymously and paces itself to the documented 30 requests per
minute of unauthenticated callers (one request every 2 seconds).
With client_id and client_secret set (Dryad application
credentials, also via DRYAD_CLIENT_ID and DRYAD_CLIENT_SECRET),
the client fetches a bearer token through the OAuth2
client-credentials flow; the token lifts the rate limit and is
required by the three download routes. The client sends
Accept: application/json and a User-Agent on every request.
Credentials resolve in the constructor: an explicit client_id or
client_secret argument wins over the settings.
datasets: DatasetsResource
cached
property
The datasets resource: browse, search, versions, and downloads.
versions: VersionsResource
cached
property
The versions resource: one version and its files.
files: FilesResource
cached
property
The files resource: metadata, digest lookup, and downloads.
reports: ReportsResource
cached
property
The reports resource: the scheduled CSV reports.
The sync twin DryadSyncClient mirrors the client method for method and
exports from the same module: from bibliofabric.dryad import
DryadSyncClient.
Settings
bibliofabric.dryad.DryadSettings
Dryad-specific client settings.
Inherits timeout, max_retries, max_retry_wait,
max_requests_per_second, max_concurrency, user_agent and
mailto from :class:bibliofabric.config.BaseApiSettings and sets
Dryad defaults: one request every 2 seconds, which is the pace of the
documented 30 requests per minute for callers without credentials, and
concurrency 2. Public metadata reads need no credentials.
client_id and client_secret come from a Dryad user account
(Applications page). When both are set, the client fetches a bearer
token through the OAuth2 client-credentials flow; the token lifts the
rate limit and is required for the file download routes.
Resources
client.datasets inherits the generic operations from bibliofabric.Resource
(get, search, iterate, collect, first, count). Only the members
that the Dryad client changes or adds are shown here.
bibliofabric.dryad.DatasetsResource
Client for the /datasets and /search endpoints.
get and :meth:versions take any Dryad DOI spelling; the DOI
travels URL-encoded (doi%3A10.5061%2Fdryad.<suffix>), as the API
requires. search/iterate/collect/first/count hit
the /search route with its filter set (:class:bibliofabric.dryad.
DryadSearchFilters); :meth:browse pages through the plain
/datasets route with its smaller filter set
(:class:bibliofabric.dryad.DryadBrowseFilters). There is no sort,
cursor, or field-selection parameter on either route.
browse(filters: BaseModel | Mapping[str, Any] | None = None, *, page: int | None = None, page_size: int | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, params: Mapping[str, Any] | None = None) -> Page[DryadDataset]
async
Page through every public dataset, newest first.
This is the plain GET /datasets browse route. filters takes
a :class:bibliofabric.dryad.DryadBrowseFilters (journal ISSN,
journal name, manuscript number, curation status) or a mapping.
For free-text and filtered queries use :meth:search.
versions(id: str, *, page: int | None = None, page_size: int | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, params: Mapping[str, Any] | None = None) -> Page[DryadVersion]
async
List the versions of one dataset, oldest first.
id is any Dryad DOI spelling; the dataset DOI addresses the
whole version family. The list starts at version 1.
download(id: str, dest: Path | str) -> Path
async
Stream the latest version of the dataset as a zip to dest.
Returns the path. The route requires a bearer token: without
client_id and client_secret set, the API answers 401 and
the client raises. The package holds all files of the version plus
its metadata.xml.
bibliofabric.dryad.VersionsResource
Client for the /versions endpoints.
Version ids are the integers in _links.self.href of a version
record; :meth:bibliofabric.dryad.DatasetsResource.versions hands
them out.
files(id: str | int, *, page: int | None = None, page_size: int | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, params: Mapping[str, Any] | None = None) -> Page[DryadFile]
async
List the files of one version, with path, size, and checksums.
download(id: str | int, dest: Path | str) -> Path
async
Stream one version as a zip to dest and return the path.
Like the dataset download, the route requires a bearer token; without credentials the API answers 401 and the client raises.
bibliofabric.dryad.FilesResource
Client for the /files endpoints.
File ids are the integers in _links.self.href of a file record;
the version files list hands them out.
by_digest(digest: str, filters: Mapping[str, Any] | None = None, *, page: int | None = None, page_size: int | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, params: Mapping[str, Any] | None = None) -> Page[DryadFile]
async
Find every public file that carries a checksum.
digest is usually an SHA-256, occasionally an MD5, hex string;
it travels URL-encoded in the path. The route pages like the other
list routes.
download(id: str | int, dest: Path | str) -> Path
async
Stream one file to dest and return the path.
The route requires a bearer token; without client_id and
client_secret set, the API answers 401 and the client raises.
bibliofabric.dryad.ReportsResource
Client for the /reports endpoints.
Dryad regenerates a handful of CSV reports on a schedule; names
lists them and :meth:download streams one to disk. The reports are
plain CSV, so no model wraps them; read the file with csv.
names() -> list[str]
async
Return the report names (GET /reports).
download(name: str, dest: Path | str) -> Path
async
Stream one report as CSV to dest and return the path.
name is a value from :meth:names, for example
datasets_with_possible_articles.
Filters
bibliofabric.dryad.DryadSearchFilters
Filters of the GET /search route.
published_since and friends accept a date (2020-01-31) or a
full timestamp. The ROR identifier filters (affiliation, facility,
funder, org) take the full https://ror.org/... spelling.
bibliofabric.dryad.DryadBrowseFilters
Filters of the GET /datasets browse route.
Models
bibliofabric.dryad.DryadDataset
One Dryad dataset: the DOI, its latest version's metadata, and stats.
identifier is the doi:10.5061/dryad.<suffix> spelling. List
items, search hits, and the detail route answer overlapping subsets,
so every field is optional. license is an SPDX license URL; every
public dataset carries CC0 (https://spdx.org/licenses/CC0-1.0.html).
doi: str | None
property
Return the doi:10.5061/dryad.<suffix> identifier.
version_id: int | None
property
Return the numeric id of the current version, from the links.
bibliofabric.dryad.DryadVersion
One version of a Dryad dataset.
The numeric version id travels in _links.self.href
(/api/v2/versions/<id>), not as a field; :attr:id reads it from
there.
id: int | None
property
Return the numeric version id from _links.self.href.
bibliofabric.dryad.DryadFile
One file inside a dataset version.
The file id travels in _links.self.href (/api/v2/files/<id>),
not as a field; :attr:id reads it from there.
id: int | None
property
Return the numeric file id from _links.self.href.
version_id: int | None
property
Return the numeric version id the file belongs to.
bibliofabric.dryad.DryadAuthor
One author of a dataset or version.
The list routes fill first_name and last_name; email,
affiliation, order, and roles are often None.
name: str
property
Return the author name as Given Family, empty when absent.
Helpers
bibliofabric.dryad.normalize_dryad_doi(value: str) -> str
Return the doi:10.5061/dryad.<suffix> spelling behind value.
Accepts the bare DOI (10.5061/dryad.7rh4625), the API spelling
(doi:10.5061/dryad.7rh4625), a doi.org URL of the DOI, and
datadryad.org URLs (https://datadryad.org/dataset/doi:10.5061/
dryad.7rh4625, https://datadryad.org/datasets/doi%3A10.5061%2F
dryad.7rh4625, and the legacy https://datadryad.org/dryad.7rh4625).
DOIs are case-insensitive, so the answer is lowercased. A value outside
the Dryad prefix raises :class:ConfigurationError.