Skip to content

API reference

Generated from the source with mkdocstrings.

Client

bibliofabric.raid.RaidClient

Client for the RAiD Federation API at https://api.raid.org.

The API is public and read-only; it serves the open-access RAiDs of the federated registration agencies and needs no credentials. mailto sets the contact address in the User-Agent; an explicit argument wins over the settings value.

raids: RaidsResource cached property

The RAiD search and lookup resource.

service_points: ServicePointsResource cached property

The service point directory of the federated agencies.

The sync twin RaidSyncClient mirrors the client method for method and exports from the same module: from bibliofabric.raid import RaidSyncClient.

Settings

bibliofabric.raid.RaidSettings

RAiD Federation API client settings.

Inherits timeout, max_retries, max_retry_wait, max_requests_per_second, max_concurrency, rate_limits, user_agent and mailto from :class:bibliofabric.config.BaseApiSettings and sets RAiD defaults (2 req/s, concurrency 2). The API is public and read-only; it needs no credentials.

Resources

Each resource inherits the generic operations from bibliofabric.Resource (get, search, iterate, collect, first, count, exists). Only the members that RAiD changes or adds are shown here.

bibliofabric.raid.RaidsResource

Client for the /raid/ routes.

Search covers the federated open-access dataset. Every match returns the complete RAiD metadata record. updated_since and created_since take epoch seconds or ISO 8601 (a date means midnight UTC, a date-time needs a time zone) and narrow a search to records changed or created at or after the time; for incremental syncs, pass sources.syncFrom of the previous crawl, available as page.meta["sources"]["syncFrom"].

search(filters: BaseModel | Mapping[str, Any] | None = None, *, query: str | None = None, sort: str | Sequence[str] | None = None, select: Sequence[str] | None = None, page: int | None = None, page_size: int | None = None, cursor: str | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, params: Mapping[str, Any] | None = None, updated_since: str | None = None, created_since: str | None = None) -> Any async

Fetch one page of RAiDs as a typed :class:~bibliofabric.paging.Page.

query is the q keyword search over every title and description: whole words, ignoring case and accents; any word may match, and double quotes define a phrase. filters carries at most one identifier filter (raid, orcid, ror, doi, related_raid, geonames, openstreetmap, webarchive, isni, isbn, ark, or rrid); it combines with query, updated_since, and created_since. :attr:Page.meta carries the sources block of the federated dataset and the pageInfo paging state.

Raises:

Type Description
ConfigurationError

sort, select, or page is set, or filters carries more than one identifier filter. The API has no such parameters, so the client sends no request.

iterate(filters: BaseModel | Mapping[str, Any] | None = None, *, query: str | None = None, sort: str | Sequence[str] | None = None, select: Sequence[str] | None = None, page_size: int | None = None, limit: int | None = None, cursor: str | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, on_page: Callable[[int, str | None], Any] | None = None, params: Mapping[str, Any] | None = None, updated_since: str | None = None, created_since: str | None = None) -> AsyncIterator[Raid]

Iterate over all matching RAiDs, page by page.

Accepts the arguments of :meth:search; limit bounds the number of records and on_page(page_number, next_cursor) checkpoints progress. Pass a cursor from a previous crawl to resume it.

collect(filters: BaseModel | Mapping[str, Any] | None = None, *, limit: int | None = None, query: str | None = None, sort: str | Sequence[str] | None = None, select: Sequence[str] | None = None, page_size: int | None = None, cursor: str | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, on_page: Callable[[int, str | None], Any] | None = None, params: Mapping[str, Any] | None = None, updated_since: str | None = None, created_since: str | None = None) -> list[Raid] async

Collect :meth:iterate output into a list, optionally bounded.

first(filters: BaseModel | Mapping[str, Any] | None = None, *, query: str | None = None, sort: str | Sequence[str] | None = None, select: Sequence[str] | None = None, page_size: int | None = 1, cursor: str | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, params: Mapping[str, Any] | None = None, updated_since: str | None = None, created_since: str | None = None) -> Raid | None async

Return the first matching RAiD, or None when there is none.

count(filters: BaseModel | Mapping[str, Any] | None = None, *, query: str | None = None, params: Mapping[str, Any] | None = None, updated_since: str | None = None, created_since: str | None = None) -> int async

Return totalCount: every RAiD matching the query, all pages.

by_prefix(prefix: str, *, updated_since: str | None = None, created_since: str | None = None, page_size: int | None = None, limit: int | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, on_page: Callable[[int, str | None], Any] | None = None, params: Mapping[str, Any] | None = None) -> list[Raid] async

List every RAiD minted under one service point's handle prefix.

The route is /raid/{prefix}/. It pages like the search route, so limit (page size, at most 100), the sync windows, and on_page behave as in :meth:search; limit bounds the number of records collected.

Raises:

Type Description
ConfigurationError

prefix is not a bare dotted prefix such as 10.26259.

bibliofabric.raid.ServicePointsResource

Client for the /service-point/ directory.

The route is unpaged and answers one JSON array with every service point of the federated agencies; each entry carries the service point's id, name, and identifierOwner ROR only.

list(*, params: Mapping[str, Any] | None = None) -> list[ServicePoint] async

Return every service point of the federated registration agencies.

Filters

bibliofabric.raid.RaidFilters

Filter model for the /raid/ route.

Identifier values accept the flexible forms upstream: the API normalises bare ids, hyphenated ids, and URLs to the canonical form it stores, and answers a malformed identifier with an empty result instead of an error. Setting more than one identifier field raises :class:bibliofabric.exceptions.ConfigurationError before a request is sent, because the API answers such a request with 400. q (keyword search), updated_since, and created_since are not filter fields; pass them as the query, updated_since, and created_since arguments of the search methods.

The upstream aliases contributor (for orcid), organisation (for ror), and relatedObject (for doi) are not model fields; pass them through params= when a raw alias is wanted.

Models

The models live in bibliofabric.raid.models and are re-exported from the top-level package. They are plain Pydantic models with aliases for the wire names (raidAgencyUrl, schemaUri, relatedRaid, identifierOwner and the rest), extra="allow", and every field optional, because a record comes verbatim from the minting agency.

bibliofabric.raid.models.Raid

A complete RAiD metadata record, as the minting agency provides it.

Unknown fields survive in model_extra, because the metadata schema evolves additively and records from different schema versions travel through the same API.

id: str | None property

The RAiD handle URL (https://raid.org/10.26259/488751).

bibliofabric.raid.models.ServicePoint

A registration agency's service point from the /service-point/ directory.

The directory returns these three fields only. id identifies the service point in RaidIdentifier.owner.service_point; ids are allocated in blocks per agency, but agencies on pre-allocation releases may share a number.