Dryad
The Dryad client (bibliofabric.dryad) is a Python client for the
Dryad API v2, the API of the Dryad data
repository. It covers datasets (browse, search, versions), version files,
file digest lookup, and the scheduled CSV reports. Every call returns a
typed Pydantic model, and the client paces itself to the limits the API
enforces. It ships an async client and a generated sync twin with the same
API. Every public dataset carries a CC0 1.0 license; the license field
of a DryadDataset holds the SPDX URL. Install follows the
setup guide.
Credentials
Metadata reads need no credentials: the client reads anonymously at the
documented pace of 30 requests per minute (one request every 2 seconds).
The three download routes (dataset zip, version zip, single file) and a
higher rate limit need a bearer token. Set DRYAD_CLIENT_ID and
DRYAD_CLIENT_SECRET from a Dryad application (account Applications page)
and the client fetches the token through the OAuth2 client-credentials
flow. You can also pass DryadClient(client_id=..., client_secret=...);
both values or neither. See settings for the
DRYAD_ variables.
Quick start
import asyncio
from bibliofabric.dryad import DryadClient
async def main():
async with DryadClient() as client:
dataset = await client.datasets.get("10.5061/dryad.7rh4625")
print(dataset.title)
page = await client.datasets.search(query="climate data", page_size=3)
print(page.total, [d.title for d in page.results])
versions = await client.datasets.versions(
"doi:10.5061/dryad.7rh4625", page_size=5
)
print(versions.total, [v.version_number for v in versions.results])
asyncio.run(main())
get() accepts a bare DOI (10.5061/dryad.7rh4625), the API spelling
(doi:10.5061/dryad.7rh4625), or a doi.org or datadryad.org URL, and
returns a DryadDataset. search() hits the /search route and returns
a Page; browse() pages through every public dataset without a query.
The script prints:
Distinct predatory behaviors in scimitar- and dirk-toothed sabertooth cats
7351 ['The niche through time: Considering phenology and demographic stages in plant distribution models', ...]
2 [1, 2]
Files and downloads
File metadata carries no id field; the client reads the id from the
_links block, so file.id and file.version_id always work:
files = await client.versions.files(93, page_size=5)
first = files.results[0]
print(first.id, first.path, first.size, first.digest_type)
same = await client.files.by_digest(first.digest)
print(same.total)
The download routes (client.datasets.download(),
client.versions.download(), client.files.download()) stream to a path
you pass and need DRYAD_CLIENT_ID and DRYAD_CLIENT_SECRET; without
credentials the API answers 401. See upstream quirks
for the details of the download routes and the report files.
Sync quick start
DryadSyncClient is generated from the async source and takes the same
calls without async:
from bibliofabric.dryad import DryadSyncClient
with DryadSyncClient() as client:
dataset = client.datasets.get("10.5061/dryad.7rh4625")
print(dataset.title)
Resources
| Resource | Routes |
|---|---|
client.datasets |
browse, search, one dataset, versions of one dataset, dataset zip |
client.versions |
one version, files of one version, version zip |
client.files |
one file, files by digest, file download |
client.reports |
report names, one report as CSV |