Metadata-Version: 2.4
Name: bibliofabric
Version: 0.10.0
Summary: Typed async and sync clients for scholarly infrastructure APIs: OpenAlex, OpenAIRE, Crossref, ROR, Zenodo, DataCite, and more, on one shared core
Author: Samuel Mok
Author-email: Samuel Mok <s.mok@utwente.nl>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Framework :: AsyncIO
Classifier: Typing :: Typed
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.9.0
Requires-Dist: pydantic-settings>=2.9.1
Requires-Dist: tenacity>=9.0.0
Requires-Python: >=3.12
Project-URL: Homepage, https://github.com/utsmok/bibliofabric
Project-URL: Repository, https://github.com/utsmok/bibliofabric
Project-URL: Documentation, https://utsmok.github.io/bibliofabric/
Project-URL: Issues, https://github.com/utsmok/bibliofabric/issues
Project-URL: Changelog, https://github.com/utsmok/bibliofabric/blob/main/packages/bibliofabric/CHANGELOG.md
Description-Content-Type: text/markdown

# bibliofabric: Python clients for scholarly metadata APIs

*Samuel Mok // s.mok@utwente.nl*

`bibliofabric` is one package with sixteen clients for scholarly metadata
APIs. A client fetches records from one source as typed models, with plain
Python calls. Every client comes in an async version and a sync version that
share the same methods, and all of them stand on one core that handles HTTP,
retries, rate limits, paging, and error mapping.

## Installation

```bash
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](https://utsmok.github.io/bibliofabric/migration/) lists
every rename.

## Use a client

```python
from bibliofabric.crossref import CrossrefSyncClient

with CrossrefSyncClient() as client:
    work = client.works.get("10.1038/nature12373")
    print(work.primary_title)
```

The script prints `Nanometre-scale thermometry in a living cell`. The async
client makes the same calls with `await`:

```python
import asyncio

from bibliofabric.crossref import CrossrefClient


async def main() -> None:
    async with CrossrefClient() as client:
        work = await client.works.get("10.1038/nature12373")
        print(work.primary_title)


asyncio.run(main())
```

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.

The [Quick start](https://utsmok.github.io/bibliofabric/quickstart/) continues
with search, paging, and error handling. The guide
[What every client gives you](https://utsmok.github.io/bibliofabric/guide/)
explains the methods that all clients share, and every client has its own
quick start and guide at
[utsmok.github.io/bibliofabric](https://utsmok.github.io/bibliofabric/).

## Clients

The sixteen clients are subpackages of `bibliofabric`, named after their
source. The [client table](https://utsmok.github.io/bibliofabric/#pick-a-client)
in the documentation is the canonical list: for each client it shows the
import, what you get, and the optional credential. No client needs a key to
start.

## What every client does the same way

Every client shares one set of methods, so you learn them once. `get()`
fetches one record. `search()` returns one page, and `iterate()`, `collect()`,
`first()`, and `count()` work with the whole result set. `batch_get()` fetches
many records at once. Clients read their settings from environment variables,
accept identifiers such as DOIs in several forms, raise typed exceptions, and
retry after a rate limit on their own.

## Build a client on the core

A client for a source that isn't covered yet defines four things: a settings
subclass, a response unwrapper, a query dialect, and one `Resource`
subclass per endpoint. The sync twin is generated from the async code. The
[guide to building a client](https://utsmok.github.io/bibliofabric/bibliofabric/writing-a-client/)
walks through every step with a complete example, and the pages next to it
describe the core (`BaseApiClient`, `QueryDialect`, `Page`, and the exception
hierarchy).

## Contributing and license

See the [contributing guide](https://utsmok.github.io/bibliofabric/contributing/).
This project is licensed under the MIT License.
