API reference
Generated from the docstrings with mkdocstrings.
Client
bibliofabric.openaire.OpenAireClient
Client for the OpenAIRE Graph API (V4) and the Scholexplorer API.
Entity resources are available as typed attributes; single-entity lookups
go through the V3 by-id routes because V4 has none. Authentication
resolves in the constructor: set refresh_token for OAuth2
refresh-token access, or set both client_id and client_secret
(settings, OPENAIRE_CLIENT_ID / OPENAIRE_CLIENT_SECRET, or
client_id / client_secret) for OAuth2 client-credentials access
against the Keycloak token endpoint; partial client credentials raise
:class:ConfigurationError, and without credentials the client is
anonymous. An explicit auth_strategy always wins.
The Scholix resource talks to the Scholexplorer host through a second internal client that shares settings and credentials but throttles itself to one request per second. See the package README and docs for usage examples of both the async and the sync variants.
request(method: str, path: str, *, params: Mapping[str, Any] | None = None, json: Any | None = None, data: Mapping[str, Any] | None = None, content: str | bytes | None = None, headers: Mapping[str, str] | None = None, timeout: float | httpx.Timeout | None = None, retry: bool | None = None, follow_redirects: bool | None = None) -> httpx.Response
async
Send a request through the core retry pipeline.
V4 accepts mailto for polite-pool admission (V3 rejects it), so the
configured contact address is attached to v4/ requests only.
aclose() -> None
async
Close both the Graph and the Scholix HTTP clients.
Settings
bibliofabric.openaire.OpenAireSettings
Tunable client behavior for the OpenAIRE Graph and Scholexplorer APIs.
Every field can be set through an environment variable prefixed with
OPENAIRE_ (for example OPENAIRE_CLIENT_ID) or a .env
file in the working directory.
Resources
research_products, projects, organizations, data_sources, and
persons support the shared Resource verbs (get, exists, search,
iterate, collect, first, count, batch_get) plus facets().
iterate() yields entity records (ResearchProduct, Project, and so on);
the Page object that search() returns is documented in the
bibliofabric paging reference.
bibliofabric.openaire.ResearchProductsResource
V4 research products endpoint: search, iterate, count, facets.
get(id) reads the V3 by-id route because V4 has no by-id endpoints.
Batch lookups use OR expressions over id and ids.doi.
get(id: str | int, *, select: Sequence[str] | None = None, params: Mapping[str, Any] | None = None) -> ResearchProduct
async
Accept DOI-shaped ids by resolving them through ids.doi.
V4 has no by-id route and V3 takes internal OpenAIRE ids only, which
cannot be derived from a DOI locally. A DOI-shaped id (bare or a
resolver URL) therefore resolves through the ids.doi filter;
internal ids keep the V3 by-id route. Raises :class:NotFoundError
when no product matches.
batch_get_by_doi(dois: Sequence[str], *, batch_size: int | None = None, concurrency: int = 4) -> dict[str, ResearchProduct]
async
Fetch research products for many DOIs in bounded, concurrent chunks.
Keys are bare, lowercased DOIs; missing DOIs are absent from the
result. The request goes out as filter=ids.doi:a|b|c.
by_orcid(orcid: str, *, limit: int = 100) -> list[ResearchProduct]
async
Return research products whose authorship carries orcid.
Accepts any spelling bibliofabric.ids.normalize_orcid handles
(bare, dashed, or an https://orcid.org/ URL); the filter sends
the hyphenated form via the V4 authorships.author.orcid field and
paginates via cursor when limit exceeds 100.
relations(filters: LinksFilters | Mapping[str, Any] | None = None, *, page: int | None = None, page_size: int | None = None) -> Page[Relation]
async
Fetch one page of relations from the Graph links route.
iterate_relations(filters: LinksFilters | Mapping[str, Any] | 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) -> AsyncIterator[Relation]
Iterate over all relations matching filters, 99 per page.
See :class:LinksResource for the missing-sort hazard of this
page-based route.
relation_types() -> list[RelationInfo]
async
Return the relation types the links endpoint can produce.
bibliofabric.openaire.ProjectsResource
V4 projects endpoint: search, iterate, count, facets.
get(id) reads the V3 by-id route because V4 has no by-id endpoints.
bibliofabric.openaire.OrganizationsResource
V4 organizations endpoint: search, iterate, count, facets.
get(id) reads the V3 by-id route because V4 has no by-id endpoints.
find_variants(names: Sequence[str], *, country: str | None = None, page_size: int | None = None) -> list[Organization]
async
Search each name fragment and return deduplicated organizations.
Records are deduplicated by exact id keeping the first match;
pending_org_:: records are kept on purpose. They carry
organization-project links that the canonical merged record lost,
which makes them the main source of undercounted org-project
links, so callers decide how to merge them.
bibliofabric.openaire.DataSourcesResource
V4 data sources endpoint: search, iterate, count, facets.
get(id) reads the V3 by-id route because V4 has no by-id endpoints.
bibliofabric.openaire.PersonsResource
V4 persons endpoint: search, iterate, count, facets.
get(id) reads the V3 by-id route because V4 has no by-id endpoints.
Batch lookups by ORCID use an OR expression over ids.original.
get(id: str | int, *, select: Sequence[str] | None = None, params: Mapping[str, Any] | None = None) -> Person
async
Accept ORCID-shaped ids by resolving them through ids.original.
V4 has no by-id route and V3 takes internal OpenAIRE ids only. An
ORCID-shaped id therefore resolves through the ids.original
filter; internal ids keep the V3 by-id route. Raises
:class:NotFoundError when no person record matches.
batch_get_by_orcid(orcids: Sequence[str], *, batch_size: int | None = None, concurrency: int = 4) -> dict[str, Person]
async
Fetch person records for many ORCID iDs in bounded, concurrent chunks.
Accepts any spelling bibliofabric.ids.normalize_orcid handles. Keys
are hyphenated ORCID iDs; ORCIDs without a person record are absent from
the result. The request goes out as filter=ids.original:a|b|c.
bibliofabric.openaire.LinksResource
/v3/research-products/links: relations between research products.
This route has no cursor and no sort parameter. Page windows are therefore not pinned: if the result ordering changes between requests, pages can shift and relations can be skipped or duplicated. The iterator stops on an empty page or when the reported total has been fetched, which bounds the walk but cannot remove that upstream hazard.
Relation records carry no id and the route has no by-id form, so
get, exists, and batch_get raise :class:ConfigurationError;
reach this route through client.research_products.relations().
relation_types() -> list[RelationInfo]
async
Return the relation types the links endpoint can produce.
bibliofabric.openaire.ScholixResource
Scholix link search over the Scholexplorer host (V3 default, V2 fallback).
Backed by a dedicated internal API client for api.scholexplorer.openaire.eu
that shares the Graph client's credentials and settings but throttles
itself to one request per second (the host sends no rate-limit headers).
V3 is the default surface. Queries carrying link_provider are routed to
V2 because V3 silently ignores link_provider. Queries carrying
from_date or to_date raise :class:ConfigurationError because V3
returns zero rows for date filters and V2 silently ignores date parameters.
search(filters: ScholixFilters | Mapping[str, Any] | None = None, *, page: int | None = None, page_size: int | None = None) -> Page[ScholixRelationship]
async
Fetch one page of links as typed records.
Queries with link_provider route to V2 (V3 silently ignores it);
everything else goes to V3. Passing from_date or to_date raises
:class:ConfigurationError.
iterate(filters: ScholixFilters | Mapping[str, Any] | 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) -> AsyncIterator[ScholixRelationship]
Iterate over all matching links, 99 per page.
See :meth:search for V2/V3 routing rules and date-filter
rejection. The route has no cursor, so page windows are not pinned; the
iterator stops on an empty page or when the reported total has been
fetched.
list_link_providers(name: str | None = None) -> list[ScholixLinkProvider]
async
List Scholexplorer link providers (V2).
list_link_publishers(*, in_target: bool = True, name: str | None = None) -> list[ScholixPublisher]
async
List publishers of source or target objects (V2).
kpi() -> str
async
Return the Scholexplorer Prometheus KPI document.
LinksResource serves list reads only: get, exists, and batch_get
raise ConfigurationError because relation records carry no id and the route
has no by-id form.
Models
bibliofabric.openaire.ResearchProduct
Model representing an OpenAIRE Research Product entity.
Covers the V3/V4 response surface (47 keys observed live): titles, authors,
access rights, countries, subjects, indicators, instances, Open Access
flags, subtype-specific fields, and typed relationship lists. Inherits
id from BaseEntity.
bibliofabric.openaire.Project
Model representing an OpenAIRE Project entity.
Captures identifiers, title, funding, duration, and related metadata.
Inherits the id field from BaseEntity.
bibliofabric.openaire.Organization
Model representing an OpenAIRE Organization entity.
Captures names, website, country, persistent identifiers, funding records,
provenance, and related entity links. Inherits the id field from
BaseEntity.
bibliofabric.openaire.DataSource
Model representing an OpenAIRE Data Source entity.
A data source in OpenAIRE can be a repository, journal, aggregator, etc.
Inherits the id field from BaseEntity.
bibliofabric.openaire.Person
Model representing an OpenAIRE Person entity.
Captures names, identifiers (pid items are {value, type_code,
type_label}, e.g. ORCID), biography, topics, measures, context, and
co-authors. Inherits the id field from BaseEntity.
Reference: https://graph.openaire.eu/docs/api/entities/person
bibliofabric.openaire.Relation
A single relation link between two scholarly entities.
bibliofabric.openaire.RelationInfo
One entry of /research-products/links/relations-info.
bibliofabric.openaire.ScholixRelationship
A single Scholix relationship link between two scholarly entities.
bibliofabric.openaire.ScholixLinkProvider
A Scholix link provider or entry from /v2/LinkProvider.
bibliofabric.openaire.ScholixPublisher
A publisher of a Scholix entity or entry from /v2/LinkPublisher.
Nested value models (Pid, Instance, Container, and the rest) stay
importable from bibliofabric.openaire.models.
Filters
bibliofabric.openaire.ResearchProductsFilters
V4 filters for /v4/research-products.
Value strings may carry the operators the API accepts: a leading !
negates, >/< compare on date and numeric fields such as
impact_citation_count, sequences join with | for OR within a field
(up to 50 values), and from_/to_ pairs bound ranges.
bibliofabric.openaire.ProjectsFilters
V4 filters for /v4/projects.
bibliofabric.openaire.OrganizationsFilters
V4 filters for /v4/organizations.
bibliofabric.openaire.DataSourcesFilters
V4 filters for /v4/datasources.
bibliofabric.openaire.PersonsFilters
V4 filters for /v4/persons.
bibliofabric.openaire.LinksFilters
Query parameters for the Graph /v3/research-products/links route.
This route takes individual parameters (not the V4 filter expression), so each attribute maps to one query parameter.
bibliofabric.openaire.ScholixFilters
Query parameters for the Scholexplorer Links endpoints (V3 and V2).
One of source_pid, target_pid, source_publisher,
target_publisher, source_type, or target_type is required.
link_provider is supported on V2 only (V3 silently ignores it), so
queries carrying link_provider are routed to V2 automatically.
from_date/to_date are rejected by :class:ScholixResource with
:class:ConfigurationError because V3 returns zero rows for them and V2
silently ignores them (see docs/openaire/quirks.md).
Helpers
bibliofabric.openaire.relation_inverse(name: str) -> str | None
Return the inverse relation of name (Cites -> IsCitedBy).
Symmetric relations return the name itself; unknown names return
None.
bibliofabric.openaire.RelationName = Literal['Cites', 'IsCitedBy', 'IsSourceOf', 'IsDerivedFrom', 'IsRelatedTo', 'HasAmongTopNSimilarDocuments', 'IsAmongTopNSimilarDocuments', 'References', 'IsReferencedBy', 'HasPart', 'IsPartOf', 'IsSupplementTo', 'IsSupplementedBy', 'IsNewVersionOf', 'IsPreviousVersionOf', 'HasVersion', 'IsVersionOf', 'Continues', 'IsContinuedBy', 'Documents', 'IsDocumentedBy', 'IsIdenticalTo', 'IsOriginalFormOf', 'IsVariantFormOf', 'Reviews', 'IsReviewedBy', 'Compiles', 'IsCompiledBy', 'Obsoletes', 'IsObsoletedBy', 'Describes', 'IsDescribedBy', 'Requires', 'IsRequiredBy', 'IsMetadataOf', 'IsMetadataFor']
module-attribute
Every relation name the links endpoint can produce (both directions).
bibliofabric.openaire.RELATION_INVERSES: Final[dict[str, str]] = {'Cites': 'IsCitedBy', 'IsCitedBy': 'Cites', 'IsSourceOf': 'IsDerivedFrom', 'IsDerivedFrom': 'IsSourceOf', 'IsRelatedTo': 'IsRelatedTo', 'HasAmongTopNSimilarDocuments': 'IsAmongTopNSimilarDocuments', 'IsAmongTopNSimilarDocuments': 'HasAmongTopNSimilarDocuments', 'References': 'IsReferencedBy', 'IsReferencedBy': 'References', 'HasPart': 'IsPartOf', 'IsPartOf': 'HasPart', 'IsSupplementTo': 'IsSupplementedBy', 'IsSupplementedBy': 'IsSupplementTo', 'IsNewVersionOf': 'IsPreviousVersionOf', 'IsPreviousVersionOf': 'IsNewVersionOf', 'HasVersion': 'IsVersionOf', 'IsVersionOf': 'HasVersion', 'Continues': 'IsContinuedBy', 'IsContinuedBy': 'Continues', 'Documents': 'IsDocumentedBy', 'IsDocumentedBy': 'Documents', 'IsIdenticalTo': 'IsIdenticalTo', 'IsOriginalFormOf': 'IsVariantFormOf', 'IsVariantFormOf': 'IsOriginalFormOf', 'Reviews': 'IsReviewedBy', 'IsReviewedBy': 'Reviews', 'Compiles': 'IsCompiledBy', 'IsCompiledBy': 'Compiles', 'Obsoletes': 'IsObsoletedBy', 'IsObsoletedBy': 'Obsoletes', 'Describes': 'IsDescribedBy', 'IsDescribedBy': 'Describes', 'Requires': 'IsRequiredBy', 'IsRequiredBy': 'Requires', 'IsMetadataOf': 'IsMetadataFor', 'IsMetadataFor': 'IsMetadataOf'}
module-attribute
Inverse relation for every :data:RelationName; symmetric names map to
themselves (IsRelatedTo, IsIdenticalTo).
Sync twins
The sync twins (OpenAireSyncClient and the *SyncResource classes) mirror
the async classes above; they take the same parameters and raise the same
errors. See Sync quick start.