bibliofabric.doi
The Doi client (bibliofabric.doi) is a Python client for the DOI System proxy server at doi.org. It looks up the registration agency of a DOI, reads the Handle.net record behind it, returns the redirect a DOI resolves to, and retrieves metadata through content negotiation in every representation Crossref, DataCite, and mEDRA serve. It ships an async client and a generated sync twin with the same API. The proxy needs no credentials.
Install
uv add bibliofabric
The Doi client ships in bibliofabric 0.9.0 and newer. Requires Python 3.12 or newer.
Quick start
import asyncio
from bibliofabric.doi import DoiClient
async def main():
async with DoiClient() as client:
print(await client.agency("10.1038/nature12373"))
item = await client.csl("10.1038/nature12373")
print(item.title)
print(await client.landing_url("10.1038/nature12373"))
asyncio.run(main())
Sync usage
The generated DoiSyncClient has the same methods without async and await:
from bibliofabric.doi import DoiSyncClient
with DoiSyncClient() as client:
record = client.handle("10.1038/nature12373")
item = client.csl("10.1038/nature12373")
print(item.title)
Settings
DoiSettings loads from environment variables prefixed with DOI_ and from a .env file in the working directory. DOI_MAX_REQUESTS_PER_SECOND (default 2) and DOI_MAX_CONCURRENCY (default 2) set the request pace, DOI_TIMEOUT (default 60) sets the timeout, and DOI_FOLLOW_REDIRECTS (default off) decides whether a request follows the resolver's 302. content() always follows it, resolve() never does. doi.org publishes no rate limit, so the pace is a courtesy. The other shared fields of bibliofabric.config.BaseApiSettings also apply, such as DOI_MAX_RETRIES, DOI_MAX_RETRY_WAIT, and DOI_USER_AGENT.
Where to go next
- Registration agencies covers the
/ra/lookup, single and batched. - Handles covers the handle records, the landing URLs, the redirect of a DOI, and its redirect targets.
- Metadata covers content negotiation and its media types.
- Runnable scripts live in examples/doi: a quickstart for agencies and metadata, the same with the sync twin, and a tour of the content-negotiation formats.
- The API reference is generated from the source, and upstream quirks lists what the live service does, verified on 2026-11-27 and 2026-11-28.