A previous release had provenance metadata, but this release does not. View details.
bibliofabric: Python clients for scholarly metadata APIs
Samuel Mok // s.mok@utwente.nl
bibliofabric is one package with typed asynchronous and synchronous clients
for scholarly APIs, on one shared core. The core owns what every such client
needs: HTTP with retries and throttling, authentication, error mapping, paging,
batch retrieval, identifier normalization, and typed resource clients. Each
client is a subpackage named after its source and adds only what is specific
to its API.
| Subpackage | API |
|---|---|
bibliofabric |
the core framework (no API of its own) |
bibliofabric.openalex |
OpenAlex |
bibliofabric.openaire |
OpenAIRE Graph API (V4), Scholexplorer |
bibliofabric.crossref |
Crossref REST API and the beta Data Citation API |
bibliofabric.ror |
ROR (research organizations and funders) |
bibliofabric.zenodo |
Zenodo REST API and OAI-PMH |
bibliofabric.datacite |
DataCite REST API and public GraphQL |
bibliofabric.opencitations |
OpenCitations Index and Meta APIs |
bibliofabric.doi |
DOI registration agency lookup, content negotiation, and Handle records |
bibliofabric.semanticscholar |
Semantic Scholar Graph, Recommendations, and Datasets APIs |
bibliofabric.orcid |
ORCID Public API v3.0 |
bibliofabric.europepmc |
Europe PMC REST web services and annotations API |
bibliofabric.wikidata |
Wikidata (action API, REST API, and SPARQL) |
bibliofabric.doaj |
DOAJ (open access journals and articles) |
bibliofabric.issn |
ISSN Portal |
bibliofabric.arxiv |
arXiv API |
bibliofabric.rxiv |
bioRxiv and medRxiv API |
Installation
uv add bibliofabric
Requires Python 3.12 or newer. The clients aireloom, aletheca, and
stavrophora were folded into this package as bibliofabric.openaire,
bibliofabric.openalex, and bibliofabric.crossref; the
migration guide lists
every rename.
Using a client
Every client ships an async client (<Source>Client) and a generated sync
twin (<Source>SyncClient) with the same API:
from bibliofabric.openalex import OpenAlexClient, OpenAlexSyncClient, WorksFilters
filters = WorksFilters(publication_year=2024, is_oa=True)
async with OpenAlexClient() as client:
page = await client.works.search(filters, query="photosynthesis")
with OpenAlexSyncClient() as client:
page = client.works.search(filters, query="photosynthesis")
The sync client uses httpx.Client, time.sleep, and threads; it never
starts an event loop, so it works in plain scripts, in Jupyter, and inside a
running event loop. Each client documents its endpoints, filters, credentials,
and the quirks of its upstream API at
utsmok.github.io/bibliofabric.
Building a client
A client defines four things: a settings subclass, a response unwrapper, a
query dialect, and one ResourceClient subclass per endpoint.
from bibliofabric import (
BaseApiClient,
BaseApiSettings,
QueryDialect,
ResourceClient,
ResponseUnwrapper,
)
from pydantic import BaseModel
from pydantic_settings import SettingsConfigDict
class FooSettings(BaseApiSettings):
model_config = SettingsConfigDict(
env_prefix="FOO_", env_file=".env", extra="ignore"
)
class Work(BaseModel):
id: str = ""
title: str = ""
doi: str | None = None
class FooUnwrapper:
"""Unwraps the Foo API envelope: {"results": [...], "total": n}."""
def results(self, body):
return body.get("results", [])
def item(self, body):
return body
def total(self, body):
return body.get("total")
def next_cursor(self, body):
return body.get("next_cursor")
def meta(self, body):
return {k: v for k, v in body.items() if k != "results"}
DIALECT = QueryDialect(
page_size_param="per_page",
max_page_size=200,
query_param="search",
select_param="select",
)
class Works(ResourceClient[Work]):
path = "works"
model = Work
dialect = DIALECT
class FooClient(BaseApiClient):
def __init__(self, settings=None, auth=None):
super().__init__(
base_url="https://api.foo.org/v1",
settings=settings or FooSettings(),
unwrapper=FooUnwrapper(),
auth=auth,
)
self.works = Works(self)
Using the client:
async with FooClient() as client:
work = await client.works.get("W123") # 404 raises NotFoundError
page = await client.works.search(query="algae") # returns Page[Work]
async for work in client.works.iterate(page_size=100, limit=500):
...
count = await client.works.count()
batch = await client.works.batch_get(["W1", "W2", "W3"])
get(), search(), and count() return typed results; iteration supports
cursor, page, and offset paging depending on the dialect. Errors, retries, and
limits are described in the errors page.
Every client built on the framework also gets a generated sync twin. Sync
classes follow the FooClient -> FooSyncClient naming rule:
with FooSyncClient() as client:
work = client.works.get("W123")
page = client.works.search(query="algae")
for work in client.works.iterate(page_size=100, limit=500):
...
The building a client guide walks through adding a client to this package.
Contributing and license
See the contributing guide. This project is licensed under the MIT License.
Metadata
Release files for bibliofabric 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Loss of provenance
These files do not have provenance metadata, despite files in a prior release including this data.
We recommend further investigation before installing these files. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bibliofabric-0.9.0.tar.gz | 446.8 kB | Without provenance | Details for bibliofabric-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bibliofabric-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for bibliofabric-0.9.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / bibliofabric-0.9.0.tar.gz
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | bibliofabric-0.9.0.tar.gz |
|---|---|
| Size | 446.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f30e3f3aa288e43f41fcea179210255fc1ad5459d6cfaa71a85263c44bf2c17a
|
|
BLAKE2b-256 checksum How to use checksums |
e7c0151be26c2d8d0ab24a99f00aa3150365373c0e6400b181ce60a881d0c65e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / bibliofabric-0.9.0-py3-none-any.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | bibliofabric-0.9.0-py3-none-any.whl |
|---|---|
| Size | 654.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b5ed1658640d49c948cea4ef6b51ad61cd302ba9fcbd8ad9d725345ab715ca7
|
|
BLAKE2b-256 checksum How to use checksums |
74f00bb145432c6572767f7d8aadce65410400bcf705235b7c35335844b6556c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for bibliofabric 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Loss of provenance
A previous release of these files had provenance metadata, but this release does not.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Release comparison
- Removed 0.6.0 2 files With provenance
- Added 0.9.0 2 files Without provenance
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.